Skip to content

Commit

Permalink
Committer: Tamio Vesa Nakajima <[email protected]>
Browse files Browse the repository at this point in the history
Made a testing module (+ minor changes to src)
 Changes to be committed:
	modified:   src/lib.sh
	modified:   src/run.sh
	new file:   test/aplusb/eval/eval.cpp
	new file:   test/aplusb/eval/makefile
	new file:   test/aplusb/incf/fixed
	new file:   test/aplusb/incf/random
	new file:   test/aplusb/ingen/ingen.cpp
	new file:   test/aplusb/ingen/makefile
	new file:   test/aplusb/okgen/makefile
	new file:   test/aplusb/okgen/okgen.cpp
	new file:   test/aplusb/src/ok.cpp
	new file:   test/aplusb/src/tle.cpp
	new file:   test/aplusb/src/wa.cpp
	new file:   test/aplusb/testmanifest
	new file:   test/correct_output
	new file:   test/test_everything.sh
  • Loading branch information
Tamio Vesa Nakajima authored and Tamio Vesa Nakajima committed May 20, 2018
1 parent eba9d34 commit 4c43c4c
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 2 deletions.
Empty file added examples/aplusb/incf/makefile
Empty file.
Empty file added examples/aplusb/src/makefile
Empty file.
Binary file added examples/aplusb/stage/aplusb.bin
Binary file not shown.
Empty file added examples/aplusb/stage/aplusb.in
Empty file.
9 changes: 9 additions & 0 deletions examples/aplusb/todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TODO:

- make an evaluator (should read from $problemname.out and $problemname.ok, write the evaluation message to stderr and the # of points to cout
- make an input generator (should read configuration from $problemname.cf and write the input to $problemname.in)
- make an ok generator (should read the # of points from $problemname.points, the input from $problemname.in, and write to ok to $problemname.ok)
- make a testmanifest (each line should contain a group of tests, described by the # of tests, the configuration file, and the # of points for that group)
- call ./buildtests.sh
- add source files to src
- call ./run.sh
2 changes: 1 addition & 1 deletion src/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ evaluate_src_test () {
source problemconfig.sh

# clear any previous messages
echo -en " \r"
echo -en "\r \r"

# Output an appropriate messgae
echo -en "Doing $testname\r"
Expand Down
2 changes: 1 addition & 1 deletion src/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ for src in $srcs ; do
done

# Clear "Doing test ..."
echo -en " \r"
echo -en "\r \r"

# Output the table
column -t $table
Expand Down
22 changes: 22 additions & 0 deletions test/aplusb/eval/eval.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

int main(){
ifstream fout("aplusb.out");
ifstream fok("aplusb.ok");

int points = 0;
fok >> points;

string s1, s2;
while(fok >> s1){
if(!bool(fout >> s2) || s1 != s2){
cerr << "WA" << endl;
cout << 0 << endl;
return 0; } }

cerr << "OK" << endl;
cout << points << endl;
return 0; }
2 changes: 2 additions & 0 deletions test/aplusb/eval/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
../eval/eval.bin:
g++ eval.cpp -std=c++11 -o ../eval/eval.bin
1 change: 1 addition & 0 deletions test/aplusb/incf/fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 0 1
1 change: 1 addition & 0 deletions test/aplusb/incf/random
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 0 0
16 changes: 16 additions & 0 deletions test/aplusb/ingen/ingen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <fstream>
using namespace std;

int main(){
ifstream f("aplusb.cf");
ofstream g("aplusb.in");
bool fixed;
int x, y;
f >> fixed >> x >> y;

if(fixed) g << x << ' ' << y << endl;
else{
srand(time(nullptr));
g << rand() << ' ' << rand() << endl; }
return 0; }
2 changes: 2 additions & 0 deletions test/aplusb/ingen/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
../ingen/ingen.bin:
g++ ingen.cpp -std=c++11 -o ../ingen/ingen.bin
2 changes: 2 additions & 0 deletions test/aplusb/okgen/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
../okgen/okgen.bin:
g++ okgen.cpp -std=c++11 -o ../okgen/okgen.bin
14 changes: 14 additions & 0 deletions test/aplusb/okgen/okgen.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <fstream>
using namespace std;

int main(){
ifstream points("aplusb.points");
ifstream f("aplusb.in");
ofstream g("aplusb.ok");

long long p, x, y;
f >> x >> y;
points >> p;
g << p << endl;
g << x+y << endl;
return 0; }
10 changes: 10 additions & 0 deletions test/aplusb/src/ok.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <fstream>
using namespace std;

int main(){
ifstream f("aplusb.in");
ofstream g("aplusb.out");
long long x, y;
f >> x >> y;
g << x+y << endl;
return 0; }
2 changes: 2 additions & 0 deletions test/aplusb/src/tle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int main(){
while(true){} }
4 changes: 4 additions & 0 deletions test/aplusb/src/wa.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <iostream>
using namespace std;

int main(){}
2 changes: 2 additions & 0 deletions test/aplusb/testmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 fixed 10
3 random 90
25 changes: 25 additions & 0 deletions test/correct_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
0
1
2
3
ok.cpp
Test Message Time Points
aplusb-0.in OK 0.030 10
aplusb-1.in OK 0.011 30
aplusb-2.in OK 0.013 30
aplusb-3.in OK 0.014 30
SCORE: 100
tle.cpp
Test Message Time Points
aplusb-0.in TLE 1.013 0
aplusb-1.in TLE 1.013 0
aplusb-2.in TLE 1.013 0
aplusb-3.in TLE 1.015 0
SCORE: 0
wa.cpp
Test Message Time Points
aplusb-0.in WA 0.012 0
aplusb-1.in WA 0.014 0
aplusb-2.in WA 0.020 0
aplusb-3.in WA 0.009 0
SCORE: 0
25 changes: 25 additions & 0 deletions test/test_everything.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project_directory=`mktemp -d`

echo Building project
echo $'aplusb\n0.1' | ./makeproject.sh $project_directory

echo Copying files into project
cp test/aplusb/incf/* $project_directory/aplusb/incf
cp test/aplusb/ingen/* $project_directory/aplusb/ingen
cp test/aplusb/okgen/* $project_directory/aplusb/okgen
cp test/aplusb/eval/* $project_directory/aplusb/eval
cp test/aplusb/src/* $project_directory/aplusb/src
cp test/aplusb/testmanifest $project_directory/aplusb/testmanifest


cd $project_directory/aplusb

output_file=`mktemp`

echo Running sources
./buildtests.sh
./run.sh

echo Cleanup

rm -r $project_directory

0 comments on commit 4c43c4c

Please sign in to comment.