mirror of https://github.com/aamine/cbc
* unit: new unit test suite.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4045 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
6164216de3
commit
6a847efed7
|
|
@ -1,3 +1,7 @@
|
|||
Tue Sep 23 20:42:38 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* unit: new unit test suite.
|
||||
|
||||
Mon Sep 22 01:45:49 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test/div.cb: test %esi usage.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
JAVA = java
|
||||
JAVAC = javac
|
||||
CLASSPATH = .:../lib/cbc.jar:./junit-4.5.jar
|
||||
CLASSES = $(patsubst %.java,%.class,$(wildcard Test*.java))
|
||||
|
||||
test: $(CLASSES)
|
||||
$(JAVA) -classpath $(CLASSPATH) TestAll
|
||||
|
||||
%.class: %.java
|
||||
$(JAVAC) -classpath $(CLASSPATH) $<
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
import org.junit.runners.*;
|
||||
import org.junit.runners.Suite.*;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({
|
||||
TestClonableIterator.class,
|
||||
TestTextUtils.class
|
||||
})
|
||||
public class TestAll {
|
||||
static public void main(String[] args) {
|
||||
JUnitCore.main(TestAll.class.getName());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
import net.loveruby.cflat.utils.ClonableIterator;
|
||||
import java.util.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestClonableIterator {
|
||||
static public void main(String[] args) {
|
||||
JUnitCore.main(TestClonableIterator.class.getName());
|
||||
}
|
||||
|
||||
@Test public void hasNext_0() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
ClonableIterator it = new ClonableIterator(list);
|
||||
assertEquals("[].hasNext #1", false, it.hasNext());
|
||||
assertEquals("[].hasNext #2", false, it.hasNext());
|
||||
}
|
||||
|
||||
@Test public void hasNext_1() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
list.add(1);
|
||||
ClonableIterator it = new ClonableIterator(list);
|
||||
assertEquals("[1].hasNext #1", true, it.hasNext());
|
||||
assertEquals("[1].hasNext #2", true, it.hasNext());
|
||||
it.next();
|
||||
assertEquals("[].hasNext #1", false, it.hasNext());
|
||||
assertEquals("[].hasNext #2", false, it.hasNext());
|
||||
}
|
||||
|
||||
@Test public void hasNext_2() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
ClonableIterator it = new ClonableIterator(list);
|
||||
assertEquals("[1,2].hasNext #1", true, it.hasNext());
|
||||
assertEquals("[1,2].hasNext #2", true, it.hasNext());
|
||||
it.next();
|
||||
assertEquals("[2].hasNext #1", true, it.hasNext());
|
||||
assertEquals("[2].hasNext #2", true, it.hasNext());
|
||||
it.next();
|
||||
assertEquals("[].hasNext #1", false, it.hasNext());
|
||||
assertEquals("[].hasNext #2", false, it.hasNext());
|
||||
}
|
||||
|
||||
@Test public void next() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
ClonableIterator it = new ClonableIterator(list);
|
||||
assertEquals("[1,2].next", 1, it.next());
|
||||
assertEquals("[2].next", 2, it.next());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static net.loveruby.cflat.utils.TextUtils.*;
|
||||
|
||||
public class TestTextUtils {
|
||||
static public void main(String[] args) {
|
||||
JUnitCore.main(TestTextUtils.class.getName());
|
||||
}
|
||||
|
||||
@Test public void test_dumpString() {
|
||||
assertEquals("dumpString #1", "\"\"", dumpString(""));
|
||||
}
|
||||
|
||||
@Test public void test_isPrintable() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
main() {
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
run_class TestAll
|
||||
else
|
||||
for t in "$@"
|
||||
do
|
||||
run_class $t
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
run_java() {
|
||||
java -classpath .:../lib/cbc.jar:./junit-4.5.jar "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in New Issue