]> mj.ucw.cz Git - eval.git/commitdiff
Added test cases for the tokenizing judge.
authorMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 19:25:26 +0000 (20:25 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 19:25:26 +0000 (20:25 +0100)
judge/Makefile
judge/judge-tok.t [new file with mode: 0644]

index 149024e78df49fc3ef1404ed9d246411c34acf65..686c2404ed714440ba1936ac1df5b9bcb4f9b1e2 100644 (file)
@@ -13,10 +13,11 @@ judge-tok: LDLIBS+=-lm
 judge-shuff: judge-shuff.o $(JLIB)
 filter-cmt: filter-cmt.o $(JLIB)
 
-tests: $(addsuffix .test,io token filter-cmt)
+tests: $(addsuffix .test,io token filter-cmt judge-tok)
 io.test: test-io
 token.test: test-tok
 filter-cmt.test: filter-cmt
+judge-tok.test: judge-tok
 
 %.test: %.t tester
        ./tester $<
diff --git a/judge/judge-tok.t b/judge/judge-tok.t
new file mode 100644 (file)
index 0000000..79943a4
--- /dev/null
@@ -0,0 +1,95 @@
+# Test cases for judge-tok.c
+
+# Identical input and output
+Name:  ok
+Run:   ./judge-tok $1 $2
+In1:   abc d e fgh
+       ijk lmn
+In2:   abc d e fgh
+       ijk lmn
+
+# Differences in whitespaces are OK
+Name:  ws
+Run:   ./judge-tok $1 $2
+In1:   abc       d e fgh  
+          ijk  lmn
+In2:   abc d  e fgh
+       ijk lmn
+
+# Differences in line breaks are not
+Name:  lines1
+Run:   ./judge-tok $1 $2
+In1:   abc  d
+       e fgh  
+          ijk  lmn
+In2:   abc d e fgh
+       ijk lmn
+Exit:  1
+
+# ... unless the -n switch is given
+Name:  lines2
+Run:   ./judge-tok -n $1 $2
+In1:   abc   d
+       e fgh  
+          ijk  lmn
+In2:   abc d e fgh
+       ijk lmn
+
+# Trailing empty lines are also not OK
+Name:  trail1
+Run:   echo >>$1 && ./judge-tok $1 $2
+In1:   abc d e fgh
+       ijk lmn
+In2:   abc d e fgh
+       ijk lmn
+Exit:  1
+
+# ... unless -t is given
+Name:  trail1
+Run:   echo >>$1 && ./judge-tok -t $1 $2
+In1:   abc d e fgh
+       ijk lmn
+In2:   abc d e fgh
+       ijk lmn
+
+# Differences in case are not
+Name:  case1
+Run:   ./judge-tok $1 $2
+In1:   abc d e FGH
+       IJK lmn
+In2:   abc d e fgh
+       ijk lmn
+Exit:  1
+
+# ... unless -i is given
+Name:  case2
+Run:   ./judge-tok -i $1 $2
+In1:   abc d e FGH
+       IJK lmn
+In2:   abc d e fgh
+       ijk lmn
+
+# By default, we compare everything literal
+Name:  real1
+Run:   ./judge-tok $1 $2
+In1:   0.1000001
+       1.
+       1e-50
+       1230000001
+In2:   0.1
+       1.
+       0
+       1230000000
+Exit:  1
+
+# ... but if -r is given, we allow small differences
+Name:  real2
+Run:   ./judge-tok -r $1 $2
+In1:   0.1000001
+       1.
+       1e-50
+       1230000001
+In2:   0.1
+       1.
+       0
+       1230000000