Fix string validity check
This commit is contained in:
@@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test;
|
||||
import ch.qos.logback.classic.Level;
|
||||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.HelpCommand;
|
||||
|
||||
@Command(
|
||||
name = "TestRead",
|
||||
|
@@ -1,47 +1,68 @@
|
||||
package csv;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestCSV {
|
||||
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
String length = "8";
|
||||
String path = "../export/result.csv";
|
||||
GenerateCSV csv = new GenerateCSV(map,length,path);
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
map = new HashMap<String,String>();
|
||||
length = "8";
|
||||
path = "../export/result.csv";
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotNull() {
|
||||
|
||||
map.put("21705239", "17");
|
||||
csv = new GenerateCSV(map,length,path);
|
||||
|
||||
assertFalse(csv == null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValid() {
|
||||
|
||||
map.put("21435712", "9");
|
||||
map.put("21705239", "17");
|
||||
csv = new GenerateCSV(map,length,path);
|
||||
|
||||
for (String etud : csv.etudiants.keySet()) {
|
||||
assertTrue(csv.isValid(etud));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testNotValid() {
|
||||
|
||||
map.put("21435", "9");
|
||||
map.put("1705239", "17");
|
||||
csv = new GenerateCSV(map,length,path);
|
||||
|
||||
for (String etud : csv.etudiants.keySet()) {
|
||||
assertFalse(csv.isValid(etud));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testGeneration() {
|
||||
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void createNullCSV() {
|
||||
// //We check if a CSV object cannot be created !
|
||||
// CSV c = new CSV();
|
||||
// assertEquals(null, c.getStudentNumber());
|
||||
// assertEquals(.0, c.getGrade());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void checkFalseStudentnumber() {
|
||||
// //We check if the student number is full composed of numeric digits !
|
||||
// String s = "056498a198";
|
||||
// assertEquals(false, CSV.checkStudentNumber(s));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void checkStudentNumberTooShort() {
|
||||
// //We check if the student number is enought long !
|
||||
// String s = "";
|
||||
// assertEquals(false, CSV.checkStudentNumber(s));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void checkStudentNumberTooLong() {
|
||||
// //We check if the student number is enought short !
|
||||
// String s = "012345678910111213141516";
|
||||
// assertEquals(false, CSV.checkStudentNumber(s));
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void checkCorrectStudentNumber() {
|
||||
// //We check if the student number is correct !
|
||||
// String s = "123456789";
|
||||
// assertEquals(true, CSV.checkStudentNumber(s));
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user