inRange

说明

检查指定值是否在 startend 之间, 但是不包括 end

源码

用法

inRange.test.ts
1
import { inRange } from "../../utility/number/inRange";
2
3
4
describe('inRange tests...', () => {
5
test('method inRange should compute the correct result', () => {
6
const received = [
7
{
8
value: 0,
9
start: 100,
10
end: 200,
11
},
12
{
13
value: 45,
14
start: -11,
15
end: 98,
16
},
17
{
18
value: 34,
19
start: 34,
20
end: 34,
21
},
22
{
23
value: 0,
24
start: -344,
25
end: 0,
26
},
27
];
28
const expected = [false, true, false, false];
29
30
received.forEach((v, i) => {
31
const result = inRange(v.value, v.start, v.end);
32
33
expect(result).toBe(expected[i]);
34
});
35
});
36
});
Copied!
最近更新 1yr ago
复制链接