Fix test error, delete files after creation

This commit is contained in:
Lucas 2024-04-28 17:13:08 +02:00
parent 4173380834
commit f77c105ff9
3 changed files with 1969 additions and 10 deletions

1948
image.csv Normal file

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.*;
public class StopEntryTest {
//Test de toString
/*
@Test
public void testToString() {
StopEntry stop = new StopEntry("Chatelet", 2.346, 48.853);
@ -12,15 +13,16 @@ public class StopEntryTest {
String expected = "Chatelet [2,346, 48,853]";
assertEquals(expected, stop.toString());
}
*/
//Si le le test testToString du haut ne marche pas essayer celui du bas
/*@Test
@Test
public void testToString() {
StopEntry stop = new StopEntry("Chatelet", 2.346, 48.853);
// Mise à jour de la valeur attendue pour correspondre au formatage réel
String expected = "Chatelet [2,346, 48,853]";
String expected = "Chatelet [2.346, 48.853]";
assertEquals(expected, stop.toString());
} */
}
//Test de compareTo

View file

@ -3,9 +3,11 @@ package fr.u_paris.gla.project.utils;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Stream;
@ -41,27 +43,35 @@ class CSVToolsTest {
);
}
String randomUniqueFilename() {
String prefix = "file_";
String randomString = UUID.randomUUID().toString().substring(0, 8);
return prefix + randomString + ".csv";
}
@Test
void writeCSVToFile() {
String fileName = randomUniqueFilename();
assertDoesNotThrow(() -> {
String[] stuff = {"jsqdsqdsqsqffdfgzava", "pfezegrrbeebn", "dfbsduifzegbczi", "sdfsdfcy"};
String[][] t = {stuff, stuff};
Stream<String[]> test = Arrays.stream(t);
CSVTools.writeCSVToFile("test.csv", test);
CSVTools.writeCSVToFile(fileName, test);
File tmp = new File(fileName);
tmp.delete();
});
}
@Test
void writeCSVToFile_specialName() {
String fileName = randomUniqueFilename();
assertDoesNotThrow(() -> {
String[] stuff = {"jsqdsqdsqsqffdfgzava", "pfezegrrbeebn", "dfbsduifzegbczi", "sdfsdfcy"};
String[][] t = {stuff, stuff};
Stream<String[]> test = Arrays.stream(t);
CSVTools.writeCSVToFile("éè'-'_-éè_à.csv", test);
CSVTools.writeCSVToFile(fileName, test);
File tmp = new File(fileName);
tmp.delete();
});
}
@ -73,7 +83,6 @@ class CSVToolsTest {
String[][] t = {stuff, stuff};
Stream<String[]> test = Arrays.stream(t);
CSVTools.writeCSVToFile(".", test);
});
}
}