mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
Merge branch 'main' into chesterkxng
This commit is contained in:
@@ -113,4 +113,5 @@ export function Sort(
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,8 @@ describe('numericSort function', () => {
|
||||
const separator = ' - ';
|
||||
const removeDuplicated: boolean = true;
|
||||
|
||||
|
||||
const result = numericSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('9 - 7 - 6 - 4 - 2');
|
||||
const result = lengthSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('3, 12, 126, 1523, 415689521');
|
||||
});
|
||||
|
||||
it('should sort a list with numbers and characters and remove duplicated elements', () => {
|
||||
@@ -35,8 +34,30 @@ describe('numericSort function', () => {
|
||||
const removeDuplicated: boolean = true;
|
||||
|
||||
|
||||
const result = numericSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('5 6 7 9 d h n p');
|
||||
|
||||
const result = lengthSort(array, increasing, separator, removeDuplicated);
|
||||
expect(result).toBe('d p h 9 7 ddd nfg 6555 5556');
|
||||
});
|
||||
});
|
||||
|
||||
// Define test cases for the alphabeticSort function
|
||||
describe('alphabeticSort function', () => {
|
||||
// NON CASE SENSITIVE TEST
|
||||
it('should sort a list of string in increasing order with comma separator ', () => {
|
||||
const array: any[] = ['apple', 'pineaple', 'lemon', 'orange'];
|
||||
const increasing: boolean = true;
|
||||
const separator = ', ';
|
||||
const removeDuplicated: boolean = false;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('apple, lemon, orange, pineaple');
|
||||
});
|
||||
|
||||
// Define test cases for the lengthSort function
|
||||
@@ -72,6 +93,56 @@ describe('numericSort function', () => {
|
||||
});
|
||||
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in increasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('@ + 1 9 Apple lemon Orange pineaple');
|
||||
});
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = false;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple Orange lemon Apple 9 1 + @');
|
||||
});
|
||||
|
||||
// Define test cases for the alphabeticSort function
|
||||
@@ -210,6 +281,56 @@ describe('numericSort function', () => {
|
||||
});
|
||||
|
||||
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = true;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('+ 1 9 @ Apple Orange lemon pineaple');
|
||||
});
|
||||
|
||||
});
|
||||
it('should sort a list of string and symbols (uppercase and lower) in decreasing order with comma separator ', () => {
|
||||
const array: any[] = [
|
||||
'Apple',
|
||||
'pineaple',
|
||||
'lemon',
|
||||
'Orange',
|
||||
1,
|
||||
9,
|
||||
'@',
|
||||
'+'
|
||||
];
|
||||
const increasing: boolean = false;
|
||||
const separator = ' ';
|
||||
const removeDuplicated: boolean = true;
|
||||
const caseSensitive: boolean = true;
|
||||
|
||||
const result = alphabeticSort(
|
||||
array,
|
||||
increasing,
|
||||
separator,
|
||||
removeDuplicated,
|
||||
caseSensitive
|
||||
);
|
||||
expect(result).toBe('pineaple lemon Orange Apple @ 9 1 +');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user