CSVTools Tests
This commit is contained in:
parent
4db502c8ca
commit
f37e5596f0
1 changed files with 76 additions and 0 deletions
76
src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java
Normal file
76
src/test/java/fr/u_paris/gla/project/utils/CSVToolsTest.java
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
package fr.u_paris.gla.project.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
class CSVToolsTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void readCSVFromURL_invalid() {
|
||||||
|
assertThrowsExactly(IOException.class,() -> {
|
||||||
|
Consumer<String[]> test = s -> System.out.println(Arrays.toString(s));
|
||||||
|
CSVTools.readCSVFromURL("https://google.fr",
|
||||||
|
test);
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void readCSVFromURL_valid() {
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
Consumer<String[]> test = s -> System.out.println(Arrays.toString(s));
|
||||||
|
CSVTools.readCSVFromURL("https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv",
|
||||||
|
test);
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeCSVToFile() {
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
String[] stuff = {"jsqdsqdsqsqffdfgzava", "pfezegrrbeebn", "dfbsduifzegbczi", "sdfsdfcy"};
|
||||||
|
String[][] t = {stuff, stuff};
|
||||||
|
Stream<String[]> test = Arrays.stream(t);
|
||||||
|
CSVTools.writeCSVToFile("test.csv", test);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeCSVToFile_specialName() {
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
String[] stuff = {"jsqdsqdsqsqffdfgzava", "pfezegrrbeebn", "dfbsduifzegbczi", "sdfsdfcy"};
|
||||||
|
String[][] t = {stuff, stuff};
|
||||||
|
Stream<String[]> test = Arrays.stream(t);
|
||||||
|
CSVTools.writeCSVToFile("éè'-'_-éè_à.csv", test);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeCSVToFile_invalidName() {
|
||||||
|
|
||||||
|
assertThrows( IOException.class ,() -> {
|
||||||
|
String[] stuff = {"jsqdsqdsqsqffdfgzava", "pfezegrrbeebn", "dfbsduifzegbczi", "sdfsdfcy"};
|
||||||
|
String[][] t = {stuff, stuff};
|
||||||
|
Stream<String[]> test = Arrays.stream(t);
|
||||||
|
CSVTools.writeCSVToFile(".", test);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue