Skip to content

Commit 27aa6c0

Browse files
authored
Tests for HammingCode.js
Test suite for 32-bit values in different formats.
1 parent 6e1e6e8 commit 27aa6c0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { HammingCode } from '../HammingCode'
2+
3+
test('checks HammingCode of 1110101 hex converted is 5', () => {
4+
const code = HammingCode(parseInt("1110101",16))
5+
expect(code).toBe(5)
6+
})
7+
8+
test('checks HammingCode of 10043091 hex converted is 7', () => {
9+
const code = HammingCode(parseInt("10043091",16))
10+
expect(code).toBe(7)
11+
})
12+
13+
test('checks HammingCode of 889193 hex converted is 9', () => {
14+
const code = HammingCode(parseInt("889193",16))
15+
expect(code).toBe(9)
16+
})
17+
18+
test('checks HammingCode of 1110101 hex converted is 5', () => {
19+
const code = HammingCode(parseInt("1101110",2))
20+
expect(code).toBe(5)
21+
})
22+
23+
test('checks HammingCode of 1101110 is 5', () => {
24+
const code = HammingCode(1101110)
25+
expect(code).toBe(5)
26+
})
27+
28+
test('checks HammingCode of 0x10043091 is 7', () => {
29+
const code = HammingCode(0x10043091)
30+
expect(code).toBe(7)
31+
})
32+
33+
test('checks HammingCode of 0x8891930311 is NaN (above range)', () => {
34+
const code = HammingCode(0x8891930311)
35+
expect(code).toBe(NaN)
36+
})
37+
38+
test('checks HammingCode of the Number 100 is 3', () => {
39+
const code = HammingCode((Number(100))
40+
expect(code).toBe(3)
41+
})

0 commit comments

Comments
 (0)