1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jwebunit;
20
21 import junit.framework.TestCase;
22 import net.sourceforge.jwebunit.html.Cell;
23 import net.sourceforge.jwebunit.html.Row;
24 import net.sourceforge.jwebunit.html.Table;
25
26
27
28
29
30
31
32 public class TableTest extends TestCase {
33
34
35
36
37 private Table table;
38
39
40
41
42 public void setUp() throws Exception {
43 super.setUp();
44 Cell[][] cells = new Cell[4][];
45 cells[0] = new Cell[3];
46 cells[0][0] = new Cell("", 1, 2);
47 cells[0][1] = new Cell("Average", 2, 1);
48 cells[0][2] = new Cell("Red eyes", 1, 2);
49 cells[1] = new Cell[2];
50 cells[1][0] = new Cell("height", 1, 1);
51 cells[1][1] = new Cell("width", 1, 1);
52 cells[2] = new Cell[4];
53 cells[2][0] = new Cell("Males", 1, 1);
54 cells[2][1] = new Cell("1.9", 1, 1);
55 cells[2][2] = new Cell("0.003", 1, 1);
56 cells[2][3] = new Cell("40%", 1, 1);
57 cells[3] = new Cell[4];
58 cells[3][0] = new Cell("Females", 1, 1);
59 cells[3][1] = new Cell("1.7", 1, 1);
60 cells[3][2] = new Cell("0.002", 1, 1);
61 cells[3][3] = new Cell("43%", 1, 1);
62 table = new Table(cells);
63 }
64
65
66
67
68
69 public final void testAssertSubTableEquals() {
70 String[] r1 = { "Males", "1.9", "0.003", "40%" };
71 String[] r2 = { "Females", "1.7", "0.002", "43%" };
72 Table sub = new Table();
73 sub.appendRow(new Row(r1));
74 sub.appendRow(new Row(r2));
75 table.assertSubTableEquals(2, sub);
76 }
77
78
79
80
81
82 public final void testAssertSubTableMatch() {
83 String[] r1 = { "Mal(e|r)s", "1\\.?", "0\\.003", "40\\%" };
84 String[] r2 = { "Fem(.)les", "1\\.?", "0[:punct:]002", "43\\%" };
85 Table sub = new Table();
86 sub.appendRow(new Row(r1));
87 sub.appendRow(new Row(r2));
88 table.assertSubTableMatch(2, sub);
89 }
90 }