diff --git a/src/__tests__/index.spec.ts b/src/__tests__/index.spec.ts index 7654a68..1eaad11 100644 --- a/src/__tests__/index.spec.ts +++ b/src/__tests__/index.spec.ts @@ -5,6 +5,7 @@ import { approximatePrimeLimitWithErrors, arraysEqual, binomial, + clamp, div, dot, extendedEuclid, @@ -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); + }); +});