Skip to content
Snippets Groups Projects
Commit 09c6e88f authored by Richard Schmidt's avatar Richard Schmidt
Browse files

Test CsvXAlignedCategoriesParser

parent 0911cd2a
No related branches found
No related tags found
1 merge request!18Feat/csvparser tests
, Reihe a , Reihe b , Reihe c, Reihe d
, Reihe a , Reihe b , Reihe c , Reihe d
Kat.1 ,3 ,"2,5" ,1 ,3
Kat.2 ,4 ,3 ,2 ,5
Kat.3 ,"4,5" ,3 ,1,"0,2"
......
package de.tudresden.inf.mci.brailleplot.csvparser;
import org.junit.jupiter.api.Test;
public class CsvParserTest {
/*
@Test
public void testCsvParser() {
}
@Test
public void testParse() {
}
*/
}
package de.tudresden.inf.mci.brailleplot.csvparser;
import de.tudresden.inf.mci.brailleplot.datacontainers.CategoricalPointListContainer;
import de.tudresden.inf.mci.brailleplot.datacontainers.PointList;
import de.tudresden.inf.mci.brailleplot.datacontainers.PointListContainer;
import de.tudresden.inf.mci.brailleplot.point.Point2DDouble;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Iterator;
import java.util.List;
public class CsvXAlignedCategoriesParserTest {
/*
CsvXAlignedCategoriesParser parser = new CsvXAlignedCategoriesParser();
List<? extends List<String>> csvDataHorizontal = ;
List<? extends List<String>> csvDataVertical = ;
PointListContainer<PointList> resultHorizontal = ;
PointListContainer<PointList> resultVertical = ;
@Test
public void testHorizontalParsing () {
Assertions.assertEquals(resultHorizontal, () -> {
parser.parseAsHorizontalDataSets(csvDataHorizontal);
});
public static CsvParser parser;
@BeforeAll
public static void initialize() {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream csvStream = classloader.getResourceAsStream("examples/csv/0_bar_chart_categorical.csv");
Reader csvReader = new BufferedReader(new InputStreamReader(csvStream));
try {
parser = new CsvParser(csvReader, ',', '\"');
} catch (Exception e) {
}
}
@Test
public void testVerticalParsing () {
Assertions.assertEquals(resultVertical, () -> {
parser.parseAsHorizontalDataSets(csvDataVertical);
});
public void testVerticalParsing() {
CategoricalPointListContainer<PointList> container = parser.parse(CsvType.X_ALIGNED_CATEGORIES, CsvOrientation.VERTICAL);
Assertions.assertEquals(container.getCategory(1), " Reihe a ");
Assertions.assertEquals(container.getCategory(2), " Reihe b ");
Assertions.assertEquals(container.getCategory(3), " Reihe c ");
Assertions.assertEquals(container.getCategory(4), " Reihe d");
Iterator containerIt = container.iterator();
PointList list_1 = (PointList) containerIt.next();
Assertions.assertEquals(list_1.getName(), "Kat.1");
Iterator it = list_1.getListIterator();
Point2DDouble point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 1.0);
Assertions.assertEquals(point.getY(), 3.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 2.0);
Assertions.assertEquals(point.getY(), 2.5);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 3.0);
Assertions.assertEquals(point.getY(), 1.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 4.0);
Assertions.assertEquals(point.getY(), 3.0);
PointList list_2 = (PointList) containerIt.next();
Assertions.assertEquals(list_2.getName(), "Kat.2");
it = list_2.getListIterator();
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 1.0);
Assertions.assertEquals(point.getY(), 4.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 2.0);
Assertions.assertEquals(point.getY(), 3.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 3.0);
Assertions.assertEquals(point.getY(), 2.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 4.0);
Assertions.assertEquals(point.getY(), 5.0);
PointList list_3 = (PointList) containerIt.next();
Assertions.assertEquals(list_3.getName(), "Kat.3");
it = list_3.getListIterator();
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 1.0);
Assertions.assertEquals(point.getY(), 4.5);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 2.0);
Assertions.assertEquals(point.getY(), 3.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 3.0);
Assertions.assertEquals(point.getY(), 1.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 4.0);
Assertions.assertEquals(point.getY(), 0.2);
PointList list_4 = (PointList) containerIt.next();
Assertions.assertEquals(list_4.getName(), "Kat.4");
it = list_4.getListIterator();
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 1.0);
Assertions.assertEquals(point.getY(), 4.5);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 2.0);
Assertions.assertEquals(point.getY(), 3.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 3.0);
Assertions.assertEquals(point.getY(), 1.0);
point = (Point2DDouble) it.next();
Assertions.assertEquals(point.getX(), 4.0);
Assertions.assertEquals(point.getY(), 0.2);
}
/*
@Test
public void testHorizontalParsing() {
}
*/
*/
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment