Check edge cases in Location getters
[cfb.git] / test / net / jaekl / cfb / store / LocationTest.java
1 package net.jaekl.cfb.store;
2
3 import static org.junit.Assert.*;
4
5 import org.junit.Test;
6
7 public class LocationTest {
8
9         @Test
10         public void testGetters() {
11                 Object[][] data = {
12                                 { Long.valueOf(1), "classname", "methodName", "methodRole", Integer.valueOf(1), Integer.valueOf(2) },
13                                 { null, null, null,  null, null, null },
14                                 { Long.valueOf(123456789012L), "name", "method", "role", Integer.valueOf(123456), Integer.valueOf(123456789) },
15                                 { Long.valueOf(723), "", "", "", null, null },
16                                 { Long.valueOf(987654321L), "class", "method", "role", Integer.valueOf(77981), Integer.valueOf(77982) },
17                                 { Long.valueOf(23), "Fred", "Wilma", "Barney", Integer.valueOf(-1), null }
18                 };
19                 
20                 for (Object[] datum : data) {
21                         Long id = (Long)datum[0];
22                         String className = (String)datum[1];
23                         String methodName = (String)datum[2];
24                         String methodRole = (String)datum[3];
25                         Integer start = (Integer)datum[4];
26                         Integer end = (Integer)datum[5];
27                         
28                         Location loc = new Location(id, className, methodName, methodRole, start, end);
29                         
30                         assertEquals(className, loc.getClassName());
31                         assertEquals(methodName, loc.getMethodName());
32                         assertEquals(methodRole, loc.getMethodRole());
33                         if (null == start) {
34                                 assertEquals((-1), loc.getStart());
35                         }
36                         else {
37                                 assertEquals(start, Integer.valueOf(loc.getStart()));
38                         }
39                         if (null == end) {
40                                 assertEquals((-1), loc.getEnd());
41                         }
42                         else {
43                                 assertEquals(end, Integer.valueOf(loc.getEnd()));
44                         }
45                 }
46         }
47
48 }