forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZigZagPatternTest.java
More file actions
19 lines (16 loc) · 789 Bytes
/
Copy pathZigZagPatternTest.java
File metadata and controls
19 lines (16 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.thealgorithms.strings.zigZagPattern;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class ZigZagPatternTest {
@Test
public void testZigZagPattern() {
String input1 = "HelloWorldFromJava";
String input2 = "javaIsAProgrammingLanguage";
Assertions.assertEquals("HooeWrrmalolFJvlda", ZigZagPattern.encode(input1, 4));
Assertions.assertEquals("jAaLgasPrmgaaevIrgmnnuaoig", ZigZagPattern.encode(input2, 4));
// Edge cases
Assertions.assertEquals("ABC", ZigZagPattern.encode("ABC", 1)); // Single row
Assertions.assertEquals("A", ZigZagPattern.encode("A", 2)); // numRows > length of string
Assertions.assertEquals("", ZigZagPattern.encode("", 3)); // Empty string
}
}