|
| 1 | +import test from 'ava' ; |
| 2 | + |
| 3 | +import { increasing , decreasing } from "@aureooms/js-compare" ; |
| 4 | + |
| 5 | +import { isSorted } from '../../src' ; |
| 6 | + |
| 7 | +function macro ( t , array , left , right , k1 , k2 ) { |
| 8 | + |
| 9 | + const n = array.length ; |
| 10 | + |
| 11 | + t.is( k1, isSorted( increasing , array , left , right ) ) ; |
| 12 | + t.is( k2, isSorted( decreasing , array , left , right ) ) ; |
| 13 | + |
| 14 | + t.is( n, array.length ) ; |
| 15 | + |
| 16 | +} |
| 17 | + |
| 18 | +macro.title = ( _ , ...args ) => args.join(' , ') ; |
| 19 | + |
| 20 | +test( macro , [ ] , 0 , 0 , true , true ) ; |
| 21 | +test( macro , [ 0 , 1 , 2 ] , 1 , 1 , true , true ) ; |
| 22 | +test( macro , [ 1 , 1 , 1 ] , 0 , 3 , true , true ) ; |
| 23 | +test( macro , [ 1 , 2 , 3 ] , 0 , 3 , true , false ) ; |
| 24 | +test( macro , [ 1 , 2 , 4 , 3 ] , 0 , 4 , false , false ) ; |
| 25 | +test( macro , [ 1 , 0 , 1 , 1 , 2 , 3 , 1 , 0 , 1 ] , 3 , 6 , true , false ) ; |
| 26 | +test( macro , [ 1 , 0 , 1 , 1 , 2 , 3 , 1 , 0 , 1 ] , 0 , 9 , false , false ) ; |
0 commit comments