public String getClassName() { return m_className; }
public String getMethodName() { return m_methodName; }
public String getMethodRole() { return m_methodRole; }
- public int getStart() { return m_startLine; }
- public int getEnd() { return m_endLine; }
+ public int getStart() { return (null == m_startLine) ? (-1) : m_startLine.intValue(); }
+ public int getEnd() { return (null == m_endLine) ? (-1) : m_endLine.intValue(); }
public void dump(PrintWriter pw, int indent)
{
--- /dev/null
+package net.jaekl.cfb.store;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class LocationTest {
+
+ @Test
+ public void testGetters() {
+ Object[][] data = {
+ { Long.valueOf(1), "classname", "methodName", "methodRole", Integer.valueOf(1), Integer.valueOf(2) },
+ { null, null, null, null, null, null },
+ { Long.valueOf(123456789012L), "name", "method", "role", Integer.valueOf(123456), Integer.valueOf(123456789) },
+ { Long.valueOf(723), "", "", "", null, null },
+ { Long.valueOf(987654321L), "class", "method", "role", Integer.valueOf(77981), Integer.valueOf(77982) },
+ { Long.valueOf(23), "Fred", "Wilma", "Barney", Integer.valueOf(-1), null }
+ };
+
+ for (Object[] datum : data) {
+ Long id = (Long)datum[0];
+ String className = (String)datum[1];
+ String methodName = (String)datum[2];
+ String methodRole = (String)datum[3];
+ Integer start = (Integer)datum[4];
+ Integer end = (Integer)datum[5];
+
+ Location loc = new Location(id, className, methodName, methodRole, start, end);
+
+ assertEquals(className, loc.getClassName());
+ assertEquals(methodName, loc.getMethodName());
+ assertEquals(methodRole, loc.getMethodRole());
+ if (null == start) {
+ assertEquals((-1), loc.getStart());
+ }
+ else {
+ assertEquals(start, Integer.valueOf(loc.getStart()));
+ }
+ if (null == end) {
+ assertEquals((-1), loc.getEnd());
+ }
+ else {
+ assertEquals(end, Integer.valueOf(loc.getEnd()));
+ }
+ }
+ }
+
+}