removed these tests since CPD has its own module now
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@610 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
pmd/regress/test/net/sourceforge/pmd/cpd
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 10:41:25 AM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CPDTest extends TestCase{
|
||||
public CPDTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() throws Throwable {
|
||||
CPD cpd = new CPD();
|
||||
cpd.add("1", "helloworld");
|
||||
cpd.add("2", "hellothere");
|
||||
cpd.go(5);
|
||||
Results occs = cpd.getResults();
|
||||
Iterator i = occs.getOccurrences(new Tile(getHelloTokens()));
|
||||
assertTrue(i.hasNext());
|
||||
Token tok = (Token)i.next();
|
||||
if (tok.getTokenSrcID().equals("1")) {
|
||||
assertEquals(0, tok.getIndex());
|
||||
} else {
|
||||
assertEquals("2", tok.getTokenSrcID());
|
||||
assertEquals(0, tok.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
public void testBasic2() throws Throwable {
|
||||
CPD cpd = new CPD();
|
||||
cpd.add("1", "helloworld");
|
||||
cpd.add("2", "hellothere");
|
||||
cpd.go(4);
|
||||
Results results = cpd.getResults();
|
||||
Iterator i = results.getOccurrences(new Tile(getHelloTokens()));
|
||||
assertTrue(i.hasNext());
|
||||
Token tok = (Token)i.next();
|
||||
if (tok.getTokenSrcID().equals("1")) {
|
||||
assertEquals(0, tok.getIndex());
|
||||
} else {
|
||||
assertEquals("2", tok.getTokenSrcID());
|
||||
assertEquals(0, tok.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
private List getHelloTokens() {
|
||||
List tokens = new ArrayList();
|
||||
Token tok = new Token('h', 0, "1");
|
||||
tokens.add(tok);
|
||||
Token tok1 = new Token('e', 1, "1");
|
||||
tokens.add(tok1);
|
||||
Token tok3 = new Token('l', 2, "1");
|
||||
tokens.add(tok3);
|
||||
Token tok4 = new Token('l', 3, "1");
|
||||
tokens.add(tok4);
|
||||
Token tok5 = new Token('o', 4, "1");
|
||||
tokens.add(tok5);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 2:06:36 PM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class GSTTest extends TestCase {
|
||||
public GSTTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
TokenList ts1 = GSTTest.createHelloTokenSet("foo");
|
||||
TokenList ts2 = GSTTest.createHelloTokenSet("bar");
|
||||
TokenSets tss = new TokenSets();
|
||||
tss.add(ts1);
|
||||
tss.add(ts2);
|
||||
GST gst = new GST(tss, 5);
|
||||
Results results = gst.crunch();
|
||||
assertEquals(1, results.size());
|
||||
Tile tile = (Tile)results.getTiles().next();
|
||||
assertEquals("hello", tile.getImage());
|
||||
Iterator occs = results.getOccurrences(tile);
|
||||
assertTrue(occs.hasNext());
|
||||
while (occs.hasNext()) {
|
||||
Token tok = (Token)occs.next();
|
||||
if (tok.getTokenSrcID().equals("foo")) {
|
||||
assertEquals(0, tok.getIndex());
|
||||
} else {
|
||||
assertEquals("bar", tok.getTokenSrcID());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static TokenList createHelloTokenSet(String id) {
|
||||
TokenList ts = new TokenList(id);
|
||||
ts.add(new Token('h', 0, id));
|
||||
ts.add(new Token('e', 1, id));
|
||||
ts.add(new Token('l', 2, id));
|
||||
ts.add(new Token('l', 3, id));
|
||||
ts.add(new Token('o', 4, id));
|
||||
return ts;
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 12:25:01 PM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class OccurrencesTest extends TestCase {
|
||||
public OccurrencesTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
Occurrences occs = new Occurrences(new TokenSets());
|
||||
assertTrue(!occs.contains(new Token('h', 0, "foo")));
|
||||
assertTrue(!occs.getTiles().hasNext());
|
||||
assertTrue(occs.isEmpty());
|
||||
assertEquals(0, occs.size());
|
||||
|
||||
occs = new Occurrences((new TokenSets(GSTTest.createHelloTokenSet("foo"))));
|
||||
assertEquals(4, occs.size());
|
||||
assertTrue(occs.contains(new Token('h', 0, "foo")));
|
||||
Iterator i = occs.getOccurrences(new Tile(new Token('h', 0, "foo")));
|
||||
assertTrue(i.hasNext());
|
||||
assertTrue(occs.getTiles().hasNext());
|
||||
int count = 0;
|
||||
for (Iterator foo = occs.getTiles(); foo.hasNext();) {
|
||||
foo.next();
|
||||
count++;
|
||||
}
|
||||
assertEquals(4, count);
|
||||
}
|
||||
|
||||
public void testInitialFrequencyCount() {
|
||||
Occurrences occs = new Occurrences((new TokenSets(GSTTest.createHelloTokenSet("foo"))));
|
||||
|
||||
Iterator i = occs.getOccurrences(new Tile(new Token('h', 0, "foo")));
|
||||
Token tok = (Token)i.next();
|
||||
assertEquals("foo", tok.getTokenSrcID());
|
||||
assertEquals(0,tok.getIndex());
|
||||
}
|
||||
|
||||
public void testContains() {
|
||||
Occurrences occs = new Occurrences((new TokenSets(GSTTest.createHelloTokenSet("foo"))));
|
||||
assertTrue(occs.contains(new Token('h', 0, "foo")));
|
||||
}
|
||||
|
||||
public void testDeleteSolo() {
|
||||
Occurrences occs = new Occurrences((new TokenSets(GSTTest.createHelloTokenSet("foo"))));
|
||||
occs.deleteSoloTiles();
|
||||
assertEquals(1, occs.size());
|
||||
assertTrue(!occs.contains(new Token('h', 0, "foo")));
|
||||
assertTrue(occs.contains(new Token('l', 2, "foo")));
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 10:08:40 AM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.Tile;
|
||||
import net.sourceforge.pmd.cpd.Token;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileTest extends TestCase {
|
||||
public TileTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testConstructors() {
|
||||
Token tok = new Token('a', 2,"foo");
|
||||
Tile tile = new Tile(tok);
|
||||
assertEquals(1, tile.getTokenCount());
|
||||
|
||||
List tokens = new ArrayList();
|
||||
tokens.add(tok);
|
||||
tile = new Tile(tokens);
|
||||
assertEquals(1, tile.getTokenCount());
|
||||
}
|
||||
|
||||
public void testCopy() {
|
||||
Token tok = new Token('a', 2,"foo");
|
||||
Tile tile = new Tile(tok);
|
||||
Tile tileCopy = tile.copy();
|
||||
assertEquals(1, tile.getTokenCount());
|
||||
assertEquals(tok, tileCopy.getTokens().get(0));
|
||||
}
|
||||
|
||||
public void testEquality() {
|
||||
Tile tile = new Tile(new Token('a', 2,"foo"));
|
||||
Tile tile2 = new Tile(new Token('a', 2,"foo"));
|
||||
assertEquals(tile, tile2);
|
||||
assertEquals(tile.hashCode(), tile2.hashCode());
|
||||
}
|
||||
|
||||
public void testContains() {
|
||||
Token tok = new Token('a', 2,"foo");
|
||||
Tile tile = new Tile(tok);
|
||||
assertTrue(tile.contains(tok));
|
||||
assertTrue(tile.contains(new Token('a', 2,"foo")));
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
Token tok = new Token('a', 2,"foo");
|
||||
Tile tile = new Tile(tok);
|
||||
tile.add(new Token('l', 8, "bar"));
|
||||
assertEquals(2, tile.getTokenCount());
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 10:24:58 AM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.TokenList;
|
||||
import net.sourceforge.pmd.cpd.Token;
|
||||
import net.sourceforge.pmd.cpd.Tile;
|
||||
|
||||
public class TokenListTest extends TestCase{
|
||||
public TokenListTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
TokenList ts = new TokenList("foo");
|
||||
assertEquals("foo", ts.getID());
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
Token tok = new Token('l', 9, "foo");
|
||||
TokenList ts = new TokenList("foo");
|
||||
ts.add(tok);
|
||||
assertEquals(tok, ts.get(0));
|
||||
assertTrue(ts.iterator().hasNext());
|
||||
}
|
||||
|
||||
public void testHasTokenAfter() {
|
||||
assertTrue(GSTTest.createHelloTokenSet("foo").hasTokenAfter(new Tile(new Token('h', 0, "foo")), new Token('h', 0, "foo")));
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 10:36:22 AM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.TokenSets;
|
||||
import net.sourceforge.pmd.cpd.TokenList;
|
||||
import net.sourceforge.pmd.cpd.Token;
|
||||
|
||||
public class TokenSetsTest extends TestCase {
|
||||
public TokenSetsTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
Token tok = new Token('h', 0, "foo");
|
||||
TokenSets tss = new TokenSets();
|
||||
TokenList ts = new TokenList("foo");
|
||||
ts.add(tok);
|
||||
tss.add(ts);
|
||||
assertEquals(ts, tss.getTokenList(tok));
|
||||
assertTrue(tss.iterator().hasNext());
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* User: tom
|
||||
* Date: Jul 31, 2002
|
||||
* Time: 10:00:36 AM
|
||||
*/
|
||||
package test.net.sourceforge.pmd.cpd;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sourceforge.pmd.cpd.Token;
|
||||
|
||||
public class TokenTest extends TestCase {
|
||||
public TokenTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void testBasic() {
|
||||
Token t = new Token('a', 2, "foo");
|
||||
assertEquals("a", t.getImage());
|
||||
assertEquals(2, t.getIndex());
|
||||
assertEquals("foo", t.getTokenSrcID());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user