mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-23 19:47:04 -04:00
41 lines
831 B
JavaScript
41 lines
831 B
JavaScript
const {test, assert, insp} = require('scar');
|
|
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
|
|
|
|
test('util.naturalCmp()', () => {
|
|
assert.equal(typeof naturalCmp, 'function', 'is function');
|
|
|
|
[
|
|
'-1',
|
|
'0',
|
|
'00',
|
|
'000',
|
|
'001',
|
|
'01',
|
|
'02',
|
|
'1',
|
|
'3',
|
|
'a0',
|
|
'a00',
|
|
'a1',
|
|
'a2',
|
|
'a 0',
|
|
'a 00',
|
|
'a 000',
|
|
'a 01',
|
|
'a 1',
|
|
'a 2',
|
|
'a 3',
|
|
'a.1',
|
|
'a.1.0',
|
|
'a.1.1',
|
|
'a.1.1.0',
|
|
'a.1.10',
|
|
'z'
|
|
].forEach((b, idx, arr) => {
|
|
if (idx === 0) {
|
|
return;
|
|
}
|
|
const a = arr[idx - 1];
|
|
assert.equal(naturalCmp(a, b), -1, `fix#${idx} - ${insp(a)} < ${insp(b)}`);
|
|
});
|
|
});
|