diff options
author | sanine <sanine.not@pm.me> | 2023-06-25 00:06:43 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-06-25 00:06:43 -0500 |
commit | 1fa9872ad4683de387b2594ed25677cf3fd99309 (patch) | |
tree | 003cb57e325d6423387deb0de8a3fa3ac79ca56c /src/protein/protein.test.js | |
parent | 9f233aa540f01848fea62f6f5031142c6e96621a (diff) |
add protein
Diffstat (limited to 'src/protein/protein.test.js')
-rw-r--r-- | src/protein/protein.test.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/protein/protein.test.js b/src/protein/protein.test.js new file mode 100644 index 0000000..61c4896 --- /dev/null +++ b/src/protein/protein.test.js @@ -0,0 +1,29 @@ +'use strict'; + +import { compare } from './protein'; + +test('compare size-1 proteins', () => { + expect(compare([0], [0])).toBe(1); + expect(compare([0], [1])).toBe(0); + expect(compare([1], [0])).toBe(0); + expect(compare([1], [1])).toBe(1); +}); + + +test('compare larger proteins', () => { + expect(compare([0,0], [0,0])).toBe(1); + expect(compare([1,1], [1,1])).toBe(1); + expect(compare([0,1], [1,1])).toBeCloseTo(0.5); + expect(compare([0,1,0], [1,1,1])).toBeCloseTo(1/3); + expect(compare([0,1,0,1], [1,1,1,1])).toBeCloseTo(0.5); + expect(compare([0,1,0,1], [0,1,1,1])).toBeCloseTo(0.75); + expect(compare([0,1,0,1], [0,1,1,0])).toBeCloseTo(0.5); + expect(compare([0,1,0,0], [0,1,1,0])).toBeCloseTo(0.75); + expect(compare([0,1,1,0], [0,1,1,0])).toBeCloseTo(1); +}); + + +test('comparisons between differently-sized proteins throw', () => { + expect(() => compare([0], [0, 0])).toThrow(); + expect(() => compare([0, 0], [0])).toThrow(); +}); |