forked from TheAlgorithms/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_binary.test.ts
More file actions
33 lines (27 loc) · 942 Bytes
/
Copy pathadd_binary.test.ts
File metadata and controls
33 lines (27 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { addBinary } from '../add_binary'
describe('Add Binary Number', () => {
it('should add two binary numbers with no carry', () => {
const result = addBinary('1101', '1011')
expect(result).toBe('11000')
})
it('should add two binary numbers with carry', () => {
const result = addBinary('1111', '1111')
expect(result).toBe('11110')
})
it('should add two different-length binary numbers', () => {
const result = addBinary('1101', '111')
expect(result).toBe('10100')
})
it('should add two empty binary numbers', () => {
const result = addBinary('', '')
expect(result).toBe('')
})
it('should add one empty binary number to a non-empty number', () => {
const result = addBinary('1010', '')
expect(result).toBe('1010')
})
it('should add one non-empty binary number to an empty number', () => {
const result = addBinary('', '1101')
expect(result).toBe('1101')
})
})