Skip to content

Commit dcbca46

Browse files
committed
added unit tests for checking Table extreme values
1 parent 9ed1143 commit dcbca46

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

core/test/processing/data/TableTest.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,73 @@ public void parseInto() {
3636
Assert.assertEquals(people[0].name, "Person1");
3737
Assert.assertEquals(people[0].age, 30);
3838
}
39+
40+
public void testGetMaxFloat() {
41+
Table table = new Table();
42+
table.addColumn("col1", Table.FLOAT);
43+
table.addColumn("col2", Table.FLOAT);
44+
table.addColumn("col3", Table.FLOAT);
45+
46+
//Normal case with positive values
47+
TableRow row1 = table.addRow();
48+
row1.setFloat("col1", 5.5f);
49+
row1.setFloat("col2", 10.2f);
50+
row1.setFloat("col3", 3.7f);
51+
52+
TableRow row2 = table.addRow();
53+
row2.setFloat("col1", 15.8f);
54+
row2.setFloat("col2", 2.1f);
55+
row2.setFloat("col3", 8.9f);
56+
57+
assertEquals(15.8f, table.getMaxFloat(), 0.001f);
58+
59+
//Table with negative values
60+
Table table2 = new Table();
61+
table2.addColumn("col1", Table.FLOAT);
62+
TableRow row3 = table2.addRow();
63+
row3.setFloat("col1", -5.5f);
64+
TableRow row4 = table2.addRow();
65+
row4.setFloat("col1", -2.3f);
66+
67+
assertEquals(-2.3f, table2.getMaxFloat(), 0.001f);
68+
69+
//Table with missing values (NaN)
70+
Table table3 = new Table();
71+
table3.addColumn("col1", Table.FLOAT);
72+
table3.addColumn("col2", Table.FLOAT);
73+
74+
TableRow row5 = table3.addRow();
75+
row5.setFloat("col1", Float.NaN);
76+
row5.setFloat("col2", 7.5f);
77+
78+
TableRow row6 = table3.addRow();
79+
row6.setFloat("col1", 12.3f);
80+
row6.setFloat("col2", Float.NaN);
81+
82+
assertEquals(12.3f, table3.getMaxFloat(), 0.001f);
83+
84+
//Table with all missing values
85+
Table table4 = new Table();
86+
table4.addColumn("col1", Table.FLOAT);
87+
TableRow row7 = table4.addRow();
88+
row7.setFloat("col1", Float.NaN);
89+
TableRow row8 = table4.addRow();
90+
row8.setFloat("col1", Float.NaN);
91+
92+
assertTrue(Float.isNaN(table4.getMaxFloat()));
93+
94+
//Empty table
95+
Table table5 = new Table();
96+
table5.addColumn("col1", Table.FLOAT);
97+
98+
assertTrue(Float.isNaN(table5.getMaxFloat()));
99+
100+
//Single value
101+
Table table6 = new Table();
102+
table6.addColumn("col1", Table.FLOAT);
103+
TableRow row9 = table6.addRow();
104+
row9.setFloat("col1", 42.0f);
105+
106+
assertEquals(42.0f, table6.getMaxFloat(), 0.001f);
107+
}
39108
}

0 commit comments

Comments
 (0)