1
+ import { addBinary } from "../add_binary" ;
2
+
3
+ describe ( 'Add Binary Number' , ( ) => {
4
+ it ( 'should add two binary numbers with no carry' , ( ) => {
5
+ const result = addBinary ( '1101' , '1011' ) ;
6
+ expect ( result ) . toBe ( '11000' ) ;
7
+ } ) ;
8
+
9
+ it ( 'should add two binary numbers with carry' , ( ) => {
10
+ const result = addBinary ( '1111' , '1111' ) ;
11
+ expect ( result ) . toBe ( '11110' ) ;
12
+ } ) ;
13
+
14
+ it ( 'should add two different-length binary numbers' , ( ) => {
15
+ const result = addBinary ( '1101' , '111' ) ;
16
+ expect ( result ) . toBe ( '10100' ) ;
17
+ } ) ;
18
+
19
+ it ( 'should add two empty binary numbers' , ( ) => {
20
+ const result = addBinary ( '' , '' ) ;
21
+ expect ( result ) . toBe ( '' ) ;
22
+ } ) ;
23
+
24
+ it ( 'should add one empty binary number to a non-empty number' , ( ) => {
25
+ const result = addBinary ( '1010' , '' ) ;
26
+ expect ( result ) . toBe ( '1010' ) ;
27
+ } ) ;
28
+
29
+ it ( 'should add one non-empty binary number to an empty number' , ( ) => {
30
+ const result = addBinary ( '' , '1101' ) ;
31
+ expect ( result ) . toBe ( '1101' ) ;
32
+ } ) ;
33
+ } ) ;
0 commit comments