Skip to content

Commit

Permalink
Add a test for the value clamper
Browse files Browse the repository at this point in the history
  • Loading branch information
frostburn committed Dec 29, 2022
1 parent 8902b4d commit ebb5548
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
approximatePrimeLimitWithErrors,
arraysEqual,
binomial,
clamp,
div,
dot,
extendedEuclid,
Expand Down Expand Up @@ -209,3 +210,17 @@ describe('Dot product', () => {
expect(dot(b, a)).toBe(38);
});
});

describe('Value clamper', () => {
it('works for lower bounds', () => {
const value = -123.4;
const clamped = clamp(0, 128, value);
expect(clamped).toBe(0);
});

it('works for upper bounds', () => {
const value = 13881.818;
const clamped = clamp(0, 12800, value);
expect(clamped).toBe(12800);
});
});

0 comments on commit ebb5548

Please sign in to comment.