11package com .thealgorithms .bitmanipulation ;
22
33import static org .junit .jupiter .api .Assertions .*;
4+
45import org .junit .jupiter .api .Test ;
56
67/**
@@ -23,10 +24,10 @@ void testRotateLeftBasic() {
2324 void testRotateLeftWithCarry () {
2425 // Test bits carrying from left to right
2526 // Binary: 10000000_00000000_00000000_00000001
26- int value = 0x80000001 ;
27+ int value = 0x80000001 ;
2728 // After left rotate by 1: 00000000_00000000_00000000_00000011
2829 assertEquals (3 , BitRotate .rotateLeft (value , 1 ));
29-
30+
3031 // Binary: 11000000_00000000_00000000_00000000
3132 value = 0xC0000000 ;
3233 // After left rotate by 1: 10000000_00000000_00000000_00000001
@@ -74,7 +75,7 @@ void testRotateRightWithCarry() {
7475 int value = 3 ;
7576 // After right rotate by 1: 10000000_00000000_00000000_00000001
7677 assertEquals (0x80000001 , BitRotate .rotateRight (value , 1 ));
77-
78+
7879 // Binary: 00000000_00000000_00000000_00000001
7980 value = 1 ;
8081 // After right rotate by 1: 10000000_00000000_00000000_00000000
@@ -146,16 +147,14 @@ void testRotateAllZeros() {
146147 @ Test
147148 void testRotateLeftNegativeShift () {
148149 // Negative shifts should throw IllegalArgumentException
149- Exception exception = assertThrows (IllegalArgumentException .class ,
150- () -> BitRotate .rotateLeft (42 , -1 ));
150+ Exception exception = assertThrows (IllegalArgumentException .class , () -> BitRotate .rotateLeft (42 , -1 ));
151151 assertTrue (exception .getMessage ().contains ("negative" ));
152152 }
153153
154154 @ Test
155155 void testRotateRightNegativeShift () {
156156 // Negative shifts should throw IllegalArgumentException
157- Exception exception = assertThrows (IllegalArgumentException .class ,
158- () -> BitRotate .rotateRight (42 , -5 ));
157+ Exception exception = assertThrows (IllegalArgumentException .class , () -> BitRotate .rotateRight (42 , -5 ));
159158 assertTrue (exception .getMessage ().contains ("negative" ));
160159 }
161160
@@ -166,10 +165,10 @@ void testRotateLeftRightComposition() {
166165 // Rotating left then right by same amount should return original value
167166 int original = 0x12345678 ;
168167 int shift = 7 ;
169-
168+
170169 int leftRotated = BitRotate .rotateLeft (original , shift );
171170 int restored = BitRotate .rotateRight (leftRotated , shift );
172-
171+
173172 assertEquals (original , restored );
174173 }
175174
@@ -178,10 +177,10 @@ void testRotateRightLeftComposition() {
178177 // Rotating right then left by same amount should return original value
179178 int original = 0x9ABCDEF0 ;
180179 int shift = 13 ;
181-
180+
182181 int rightRotated = BitRotate .rotateRight (original , shift );
183182 int restored = BitRotate .rotateLeft (rightRotated , shift );
184-
183+
185184 assertEquals (original , restored );
186185 }
187186
@@ -191,4 +190,4 @@ void testRotateLeft31IsSameAsRotateRight1() {
191190 int value = 0x55555555 ;
192191 assertEquals (BitRotate .rotateLeft (value , 31 ), BitRotate .rotateRight (value , 1 ));
193192 }
194- }
193+ }
0 commit comments