gt

源码

https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/others/gt

说明

检查x是否大于y

用法

gt.ts
gt.test.ts
import { gt } from "./ddzy/utility/others/gt";
// ? true
const s1 = [10, 5];
const p1 = gt(s1[0], s1[1]);
console.log(p1);
console.log('-----------------');
// ? false
const s2 = [10, 10];
const p2 = gt(s2[0], s2[1]);
console.log(p2);
console.log('----------------------');
// ? false
const s3 = [10, 20];
const p3 = gt(s3[0], s3[1]);
console.log(p3);
console.log('-----------------------');
import { gt } from "../../utility/others/gt";
describe('gt tests: ', () => {
test('gt should return `true` when the param 1 that large than param2', () => {
const received = [10, 5];
const expected = true;
const result = gt(received[0], received[1]);
expect(result).toBe(expected);
});
test('gt should return `false` when the param 1 that equal with param2', () => {
const received = [10, 10];
const expected = false;
const result = gt(received[0], received[1]);
expect(result).toBe(expected);
});
test('gt should return `false` when the param 1 that small than param2', () => {
const received = [10, 20];
const expected = false;
const result = gt(received[0], received[1]);
expect(result).toBe(expected);
});
});