Skip to content

Commit ca86125

Browse files
committed
Add Base64Util with encode/decode and unit tests - add clango-format
1 parent 961cfef commit ca86125

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/main/java/com/thealgorithms/conversions/Base64Util.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*/
1010
public final class Base64Util {
1111

12-
private Base64Util() {
13-
}
12+
private Base64Util() {}
1413

1514
/**
1615
* Encodes a given string into Base64 format.
@@ -31,7 +30,8 @@ public static String encode(String input) {
3130
*
3231
* @param base64 The Base64 encoded string.
3332
* @return The decoded original text.
34-
* @throws IllegalArgumentException if base64 is null or not a valid Base64 string.
33+
* @throws IllegalArgumentException if base64 is null or not a valid Base64
34+
* string.
3535
*/
3636
public static String decode(String base64) {
3737
if (base64 == null) {

src/test/java/com/thealgorithms/conversions/Base64Test.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.junit.jupiter.params.ParameterizedTest;
88
import org.junit.jupiter.params.provider.CsvSource;
99

10-
public class Base64Test{
10+
public class Base64Test {
1111

1212
@Test
1313
// Test encoding and decoding normal strings
@@ -41,16 +41,10 @@ public void testNullInputDecode() {
4141
}
4242

4343
@ParameterizedTest
44-
@CsvSource({
45-
"invalid@@base64",
46-
"12345$%",
47-
"====",
48-
"abc?def"
49-
})
44+
@CsvSource({"invalid@@base64", "12345$%", "====", "abc?def"})
5045
// Test decoding invalid Base64 strings
5146
void testInvalidBase64Decode(String invalidBase64) {
52-
assertThrows(IllegalArgumentException.class, () -> Base64Util.decode(invalidBase64));
47+
assertThrows(IllegalArgumentException.class,
48+
() -> Base64Util.decode(invalidBase64));
5349
}
54-
5550
}
56-

0 commit comments

Comments
 (0)