|
7 | 7 | import org.junit.Test;
|
8 | 8 |
|
9 | 9 | import core.FileOperations;
|
| 10 | +import core.JSONObject; |
10 | 11 | import core.JSONProcessor;
|
11 | 12 |
|
12 | 13 | public class Tests {
|
13 | 14 |
|
14 | 15 | @Test
|
15 | 16 | public void testNumbers() {
|
16 |
| - String expected = String.join("\n", FileOperations.readFile(Path.of("src\\tests\\java\\data\\test1\\expected1.out"))); |
17 |
| - assertNotNull("Expected file content should not be null", expected); |
| 17 | + // Normalize path separators for cross-platform compatibility |
| 18 | + Path expectedPath = Path.of("src", "tests", "java", "data", "test1", "expected1.out"); |
| 19 | + Path testPath = Path.of("src", "tests", "java", "data", "test1", "test1.json"); |
18 | 20 |
|
19 |
| - String result = JSONProcessor.processJson(Path.of("src\\tests\\java\\data\\test1\\test1.json")).toString(); |
20 |
| - assertNotNull("Processed JSON should not be null", result); |
| 21 | + // Read and normalize the expected content |
| 22 | + List<String> expectedLines = FileOperations.readFile(expectedPath); |
| 23 | + assertNotNull("Expected file content should not be null", expectedLines); |
| 24 | + String expected = String.join(System.lineSeparator(), expectedLines).trim(); |
21 | 25 |
|
22 |
| - assertEquals(expected, result); |
| 26 | + // Process and normalize the actual result |
| 27 | + JSONObject processed = JSONProcessor.processJson(testPath); |
| 28 | + assertNotNull("Processed JSON should not be null", processed); |
| 29 | + String result = processed.toString().trim(); |
| 30 | + |
| 31 | + // Compare normalized strings |
| 32 | + assertEquals("JSON content does not match expected output", expected, result); |
23 | 33 | }
|
24 | 34 |
|
25 | 35 | @Test
|
|
0 commit comments