Skip to content

Commit 7004544

Browse files
authored
Create HammingWeight.test.js
Additional tests and other name changes.
1 parent a35ce8d commit 7004544

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { HammingWeight } from '../HammingWeight'
2+
3+
describe.each([
4+
{ inputVal:Number(117), expectedVal: 5 },
5+
{ inputVal:parseInt(0x9F9,16), expectedVal: 7 },
6+
{ inputVal:parseInt(0x889193,16), expectedVal: 10 },
7+
{ inputVal:10043091, expectedVal: 14},
8+
{ inputVal:parseInt("1101110",2), expectedVal: 5 },
9+
{ inputVal:parseInt(1101110,2), expectedVal: 5 }
10+
])('Resulting code checks from $inputVal', ({inputVal, expectedVal}) => {
11+
test(`returns ${expectedVal}`, () => {
12+
expect(HammingWeight(inputVal)).toBe(expectedVal)
13+
})
14+
})

0 commit comments

Comments
 (0)