# HG changeset patch # User Jittat Fakcharoenphol # Date 2010-04-28 12:40:27 # Node ID 7caf7717f3275379f86e1b85e339a9af41c1096e # Parent 01b9b35be113ed41330144e138324142f831ed85 added regression test for c++ submission diff --git a/test/data/test1_correct_cc.cc b/test/data/test1_correct_cc.cc new file mode 100644 --- /dev/null +++ b/test/data/test1_correct_cc.cc @@ -0,0 +1,13 @@ +/* +LANG: C++ +*/ +#include + +int main() +{ + int a,b,r; + r = scanf("%d %d",&a,&b); + printf("%d\n",a+b); + return 0; +} + diff --git a/test/engine_spec.rb b/test/engine_spec.rb --- a/test/engine_spec.rb +++ b/test/engine_spec.rb @@ -28,6 +28,17 @@ end + it "should grade normal submission in C++" do + cpp_lang = stub(Language, :name => 'cpp', :ext => 'cpp') + + grader_should(:grade => "test1_correct_cc.cc", + :language => cpp_lang, + :on => @problem_test_normal, + :and_report => { + :score => 135, + :comment => /^(\[|P|\])+/}) + end + it "should produce error message when submission cannot compile" do grader_should(:grade => "test1_compile_error.c", :on => @problem_test_normal, @@ -122,8 +133,9 @@ def grader_should(args) @user1 = stub(User, :id => 1, :login => 'user1') + submission = - create_submission_from_file(1, @user1, args[:on], args[:grade]) + create_submission_from_file(1, @user1, args[:on], args[:grade], args[:language]) submission.should_receive(:graded_at=) expected_score = args[:and_report][:score]