001: package org.incava.analysis;
002:
003: import java.io.*;
004: import java.util.*;
005: import junit.framework.TestCase;
006:
007: public class TestViolation extends TestCase {
008: public TestViolation(String name) {
009: super (name);
010: }
011:
012: public void testLineSameColumnSame() {
013: Violation v1, v2;
014: int comp;
015:
016: v1 = new Violation("test", 3, 3, 14, 8);
017: v2 = new Violation("test", 3, 3, 14, 8);
018: comp = v1.compareTo(v2);
019: assertEquals("comparision value", 0, comp);
020: assertTrue("equality", v1.equals(v2));
021: assertTrue("equality", v2.equals(v1));
022:
023: v1 = new Violation("test", 12, 12, 14, 8);
024: v2 = new Violation("test", 12, 12, 14, 8);
025: comp = v1.compareTo(v2);
026: assertEquals("comparision value", 0, comp);
027: assertTrue("equality", v1.equals(v2));
028: assertTrue("equality", v2.equals(v1));
029: }
030:
031: public void testLineSameColumnDifferent() {
032: Violation v1, v2;
033: int comp;
034:
035: v1 = new Violation("test", 3, 3, 14, 8);
036: v2 = new Violation("test", 3, 17, 14, 8);
037: comp = v1.compareTo(v2);
038: assertTrue("comparision value", comp < 0);
039: assertFalse("equality", v1.equals(v2));
040: assertFalse("equality", v2.equals(v1));
041:
042: comp = v2.compareTo(v1);
043: assertTrue("comparision value", comp > 0);
044:
045: v1 = new Violation("test", 3, 17, 14, 8);
046: v2 = new Violation("test", 3, 3, 14, 8);
047: comp = v1.compareTo(v2);
048: assertTrue("comparision value", comp > 0);
049: assertFalse("equality", v1.equals(v2));
050: assertFalse("equality", v2.equals(v1));
051:
052: comp = v2.compareTo(v1);
053: assertTrue("comparision value", comp < 0);
054: }
055:
056: public void testLineDifferentColumnSame() {
057: Violation v1, v2;
058: int comp;
059:
060: v1 = new Violation("test", 3, 3, 14, 8);
061: v2 = new Violation("test", 17, 3, 14, 8);
062: comp = v1.compareTo(v2);
063: assertTrue("comparision value", comp < 0);
064: assertFalse("equality", v1.equals(v2));
065: assertFalse("equality", v2.equals(v1));
066:
067: comp = v2.compareTo(v1);
068: assertTrue("comparision value", comp > 0);
069:
070: v1 = new Violation("test", 17, 3, 14, 8);
071: v2 = new Violation("test", 3, 3, 14, 8);
072: comp = v1.compareTo(v2);
073: assertTrue("comparision value", comp > 0);
074: assertFalse("equality", v1.equals(v2));
075: assertFalse("equality", v2.equals(v1));
076:
077: comp = v2.compareTo(v1);
078: assertTrue("comparision value", comp < 0);
079: }
080:
081: public void testEndLineDifferent() {
082: Violation v1, v2;
083: int comp;
084:
085: v1 = new Violation("test", 3, 3, 3, 9);
086: v2 = new Violation("test", 3, 3, 17, 9);
087: comp = v1.compareTo(v2);
088: assertTrue("comparision value", comp < 0);
089: assertFalse("equality", v1.equals(v2));
090: assertFalse("equality", v2.equals(v1));
091:
092: comp = v2.compareTo(v1);
093: assertTrue("comparision value", comp > 0);
094:
095: v1 = new Violation("test", 3, 3, 17, 9);
096: v2 = new Violation("test", 3, 3, 3, 9);
097: comp = v1.compareTo(v2);
098: assertTrue("comparision value", comp > 0);
099: assertFalse("equality", v1.equals(v2));
100: assertFalse("equality", v2.equals(v1));
101:
102: comp = v2.compareTo(v1);
103: assertTrue("comparision value", comp < 0);
104: }
105:
106: public void testEndColumnDifferent() {
107: Violation v1, v2;
108: int comp;
109:
110: v1 = new Violation("test", 3, 3, 3, 3);
111: v2 = new Violation("test", 3, 3, 3, 17);
112: comp = v1.compareTo(v2);
113: assertTrue("comparision value", comp < 0);
114: assertFalse("equality", v1.equals(v2));
115: assertFalse("equality", v2.equals(v1));
116:
117: comp = v2.compareTo(v1);
118: assertTrue("comparision value", comp > 0);
119:
120: v1 = new Violation("test", 3, 3, 3, 17);
121: v2 = new Violation("test", 3, 3, 3, 3);
122: comp = v1.compareTo(v2);
123: assertTrue("comparision value", comp > 0);
124: assertFalse("equality", v1.equals(v2));
125: assertFalse("equality", v2.equals(v1));
126:
127: comp = v2.compareTo(v1);
128: assertTrue("comparision value", comp < 0);
129: }
130:
131: }
|