From d622400ab8c3a3dbcf78760e6d117c76be32bf8a Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Thu, 19 Sep 2019 13:55:43 +0200 Subject: [PATCH] create test classe for the CSV classe --- NGCC/tests/genCSV/TestCSV.java | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 NGCC/tests/genCSV/TestCSV.java diff --git a/NGCC/tests/genCSV/TestCSV.java b/NGCC/tests/genCSV/TestCSV.java new file mode 100644 index 0000000..a2dbc9e --- /dev/null +++ b/NGCC/tests/genCSV/TestCSV.java @@ -0,0 +1,47 @@ +package genCSV; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + + +public class TestCSV { + + @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)); + } + +}