File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed
main/java/com/thealgorithms/others/cn
test/java/com/thealgorithms/others/cn Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 2
2
3
3
public final class HammingDistance {
4
4
5
- private HammingDistance () {
6
- }
5
+ private HammingDistance () {
6
+ }
7
7
8
- public static int compute (String bitsStrA , String bitsStrB ) {
9
- HammingHandler chain = new ValidateBinaryHandler ();
10
- chain .setNext (new ValidateLengthHandler ()).setNext (new ComputeHammingHandler ());
8
+ public static int compute (String bitsStrA , String bitsStrB ) {
9
+ HammingHandler chain = new ValidateBinaryHandler ();
10
+ chain .setNext (new ValidateLengthHandler ()).setNext (new ComputeHammingHandler ());
11
11
12
- return (int ) chain .handle (bitsStrA , bitsStrB );
13
- }
12
+ return (int ) chain .handle (bitsStrA , bitsStrB );
13
+ }
14
14
}
Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ public class ValidateBinaryHandlerTest {
9
9
10
10
@ Test
11
11
public void validBinaryStringsShouldPass () {
12
- handler .setNext (new MockHammingHandler ("PASSED" ));
12
+ handler .setNext (new MockHammingHandler ("PASSED" ));
13
13
Object result = handler .handle ("1010" , "0110" );
14
14
Assertions .assertThat (result ).isEqualTo ("PASSED" );
15
15
}
16
16
17
17
@ Test
18
18
public void invalidBinaryShouldThrowException () {
19
- Assertions .assertThatThrownBy (() -> handler .handle ("10A0" , "0110" ))
20
- .isInstanceOf (IllegalArgumentException .class )
21
- .hasMessageContaining ("binary string" );
19
+ Assertions .assertThatThrownBy (() -> handler .handle ("10A0" , "0110" )).isInstanceOf (IllegalArgumentException .class ).hasMessageContaining ("binary string" );
22
20
}
23
21
}
Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ public class ValidateLengthHandlerTest {
9
9
10
10
@ Test
11
11
public void validLengthShouldPass () {
12
- handler .setNext (new MockHammingHandler ("LENGTH_OK" ));
12
+ handler .setNext (new MockHammingHandler ("LENGTH_OK" ));
13
13
Object result = handler .handle ("1010" , "0110" );
14
14
Assertions .assertThat (result ).isEqualTo ("LENGTH_OK" );
15
15
}
16
16
17
17
@ Test
18
18
public void mismatchedLengthShouldThrowException () {
19
- Assertions .assertThatThrownBy (() -> handler .handle ("101" , "10" ))
20
- .isInstanceOf (IllegalArgumentException .class )
21
- .hasMessageContaining ("same length" );
19
+ Assertions .assertThatThrownBy (() -> handler .handle ("101" , "10" )).isInstanceOf (IllegalArgumentException .class ).hasMessageContaining ("same length" );
22
20
}
23
21
}
You can’t perform that action at this time.
0 commit comments