From db5e7df236e6f7e30f28f62405acd1e4f92f072f Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 18 Nov 2007 20:06:40 +0100 Subject: [PATCH] Added tests for the comment filter and fixed a bug there. --- judge/Makefile | 3 ++- judge/filter-cmt.c | 5 ++++- judge/filter-cmt.t | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 judge/filter-cmt.t diff --git a/judge/Makefile b/judge/Makefile index ccb9838..149024e 100644 --- a/judge/Makefile +++ b/judge/Makefile @@ -13,9 +13,10 @@ judge-tok: LDLIBS+=-lm judge-shuff: judge-shuff.o $(JLIB) filter-cmt: filter-cmt.o $(JLIB) -tests: $(addsuffix .test,io token) +tests: $(addsuffix .test,io token filter-cmt) io.test: test-io token.test: test-tok +filter-cmt.test: filter-cmt %.test: %.t tester ./tester $< diff --git a/judge/filter-cmt.c b/judge/filter-cmt.c index 12978ad..a7fb8cb 100644 --- a/judge/filter-cmt.c +++ b/judge/filter-cmt.c @@ -23,7 +23,10 @@ int main(void) while ((c = sgetc(i)) >= 0 && c != '\n') ; if (nl) - continue; + { + c = sgetc(i); + continue; + } } else { diff --git a/judge/filter-cmt.t b/judge/filter-cmt.t new file mode 100644 index 0000000..67adf9a --- /dev/null +++ b/judge/filter-cmt.t @@ -0,0 +1,11 @@ +# Test cases for filter-cmt.c + +Run: ./filter-cmt +In: abc//comment + de///fgh + //full-line comment + //another full-line comment + lastline +Out: abc + de + lastline -- 2.39.2