summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh2013-06-05 17:26:50 +0530
committerprathamesh2013-06-05 17:26:50 +0530
commitfc40c033a083e2a4027fdbeecfb5853e6770a7c6 (patch)
tree97c47083dd1318536d4c3722214992e0b8f2bf37
parent6667efae7acb86f60b0ebd4dabb959bed759bc16 (diff)
downloadonline_test-fc40c033a083e2a4027fdbeecfb5853e6770a7c6.tar.gz
online_test-fc40c033a083e2a4027fdbeecfb5853e6770a7c6.tar.bz2
online_test-fc40c033a083e2a4027fdbeecfb5853e6770a7c6.zip
c and cpp files isolated
-rw-r--r--testapp/docs/add.c4
-rw-r--r--testapp/docs/add.cpp6
-rw-r--r--testapp/docs/array_sum.c10
-rw-r--r--testapp/docs/array_sum.cpp10
-rw-r--r--testapp/docs/fact.c10
-rw-r--r--testapp/docs/fact.cpp16
-rw-r--r--testapp/docs/greatest.c15
-rw-r--r--testapp/docs/greatest.cpp15
-rw-r--r--testapp/docs/hello_name.c16
-rwxr-xr-xtestapp/docs/main.cpp30
-rwxr-xr-xtestapp/docs/main2.c28
-rwxr-xr-xtestapp/docs/main_array_sum.cpp32
-rwxr-xr-xtestapp/docs/main_fact.cpp30
-rwxr-xr-xtestapp/docs/main_greatest.cpp32
-rwxr-xr-xtestapp/docs/main_hello_name.c29
-rwxr-xr-xtestapp/docs/main_palindrome.cpp30
-rw-r--r--testapp/docs/palindrome.c20
-rw-r--r--testapp/docs/palindrome.cpp19
-rwxr-xr-xtestapp/docs/sample.c20
-rwxr-xr-xtestapp/docs/sample.cpp7
-rw-r--r--testapp/test_server.py54
21 files changed, 9 insertions, 424 deletions
diff --git a/testapp/docs/add.c b/testapp/docs/add.c
deleted file mode 100644
index c829971..0000000
--- a/testapp/docs/add.c
+++ /dev/null
@@ -1,4 +0,0 @@
-int add(int a,int b)
-{
- return a-b;
-}
diff --git a/testapp/docs/add.cpp b/testapp/docs/add.cpp
deleted file mode 100644
index d3b7897..0000000
--- a/testapp/docs/add.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include<stdio.h>
-int add(int a,int b)
-{
- printf("All Correct");
- return a;
-}
diff --git a/testapp/docs/array_sum.c b/testapp/docs/array_sum.c
deleted file mode 100644
index 619a23c..0000000
--- a/testapp/docs/array_sum.c
+++ /dev/null
@@ -1,10 +0,0 @@
-int array_sum(int a[5])
-{
- int i=0, sum=0;
- for(i=0;i<5;i++)
- {
- sum = sum + a[i];
- }
- return sum;
-}
-
diff --git a/testapp/docs/array_sum.cpp b/testapp/docs/array_sum.cpp
deleted file mode 100644
index 9b82d3b..0000000
--- a/testapp/docs/array_sum.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-int array_sum(int a[])
-{
- int i=0, sum=0;
- for(i=0;i<5;i++)
- {
- sum = sum + a[i];
- }
- return sum;
-}
-
diff --git a/testapp/docs/fact.c b/testapp/docs/fact.c
deleted file mode 100644
index e3665f5..0000000
--- a/testapp/docs/fact.c
+++ /dev/null
@@ -1,10 +0,0 @@
-int factorial(int a)
-{
- int i,fact=1;
- for(i=1;i<=a;a--)
- {
- fact=fact*a;
- }
- return fact;
-
-}
diff --git a/testapp/docs/fact.cpp b/testapp/docs/fact.cpp
deleted file mode 100644
index f9b7458..0000000
--- a/testapp/docs/fact.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include<stdio.h>
-int fact = 1;
-int factorial(int a)
-{
- printf("%d\n",a);
- if(a<1)
- {
- printf("\nfinal");
- return 1;
- }
- else
- {
- printf("count\n");
- return a*factorial(a-1);
- }
-}
diff --git a/testapp/docs/greatest.c b/testapp/docs/greatest.c
deleted file mode 100644
index 0194855..0000000
--- a/testapp/docs/greatest.c
+++ /dev/null
@@ -1,15 +0,0 @@
-int greatest(int a,int b,int c)
-{
- if(a>b && a>c)
- {
- return a;
- }
- else if(b>c)
- {
- return b;
- }
- else
- {
- return c;
- }
-}
diff --git a/testapp/docs/greatest.cpp b/testapp/docs/greatest.cpp
deleted file mode 100644
index 0194855..0000000
--- a/testapp/docs/greatest.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-int greatest(int a,int b,int c)
-{
- if(a>b && a>c)
- {
- return a;
- }
- else if(b>c)
- {
- return b;
- }
- else
- {
- return c;
- }
-}
diff --git a/testapp/docs/hello_name.c b/testapp/docs/hello_name.c
deleted file mode 100644
index 8fa2519..0000000
--- a/testapp/docs/hello_name.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include<string.h>
-#include<stdio.h>
-
-char *message(char a[])
-{
- return (strcat("hello",a));
-}
-
-main()
-{
- printf("he\n");
- char q[]="re";
- char s[20];
- s= message(q);
- printf("%s",s);
-}
diff --git a/testapp/docs/main.cpp b/testapp/docs/main.cpp
deleted file mode 100755
index ffd110e..0000000
--- a/testapp/docs/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern int add(int, int);
-
-template <class T>
-
-void check(T expect, T result)
-{
- if (expect == result)
- {
- //printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
- exit (1);
- }
-}
-
-int main(void)
-{
- int result;
- result = add(0,0);
- check(0, result);
- result = add(2,3);
- check(5,result);
- printf("All Correct\n");
- return 0;
-}
diff --git a/testapp/docs/main2.c b/testapp/docs/main2.c
deleted file mode 100755
index 3d28ff6..0000000
--- a/testapp/docs/main2.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern int add(int, int, int);
-
-template <class T>
-void check(T expect,T result)
-{
- if (expect == result)
- {
- printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("Incorrect:\n Expected %d got %d \n",expect,result);
- exit (0);
- }
-}
-
-int main(void)
-{
- int result;
- result = add(0,0,0);
- check(0, result);
- result = add(2,3,3);
- check(8,result);
- printf("All Correct\n");
-}
diff --git a/testapp/docs/main_array_sum.cpp b/testapp/docs/main_array_sum.cpp
deleted file mode 100755
index 72eee46..0000000
--- a/testapp/docs/main_array_sum.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern int array_sum(int []);
-
-template <class T>
-
-void check(T expect,T result)
-{
- if (expect == result)
- {
- //printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
- exit (1);
- }
-}
-
-int main(void)
-{
- int result;
- int a[55555] = {1,2,3,0,0};
- result = array_sum(a);
- check(6, result);
- int b[] = {1,2,3,4,5};
- result = array_sum(b);
- check(15,result);
- printf("All Correct\n");
- return 0;
-}
diff --git a/testapp/docs/main_fact.cpp b/testapp/docs/main_fact.cpp
deleted file mode 100755
index ff65456..0000000
--- a/testapp/docs/main_fact.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern int factorial(int);
-
-template <class T>
-
-void check(T expect, T result)
-{
- if (expect == result)
- {
- //printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
- exit (1);
- }
-}
-
-int main(void)
-{
- int result;
- result = factorial(0);
- check(1, result);
- result = factorial(3);
- check(6, result);
- printf("All Correct\n");
- return 0;
-}
diff --git a/testapp/docs/main_greatest.cpp b/testapp/docs/main_greatest.cpp
deleted file mode 100755
index fe9ff5b..0000000
--- a/testapp/docs/main_greatest.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern int greatest(int, int, int);
-
-template <class T>
-
-void check(T expect, T result)
-{
- if (expect == result)
- {
- //printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
- exit (1);
- }
-}
-
-int main(void)
-{
- int result;
- result = greatest(1, 2, 3);
- check(3, result);
- result = greatest(5, 9, 2);
- check(9, result);
- result = greatest(7, 2, 4);
- check(7, result);
- printf("All Correct\n");
- return 0;
-}
diff --git a/testapp/docs/main_hello_name.c b/testapp/docs/main_hello_name.c
deleted file mode 100755
index 71b83a2..0000000
--- a/testapp/docs/main_hello_name.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-
-void check(char expect[], char result[])
-{
- if (expect == result)
- {
- printf("Correct:expected %s got %s \n",expect,result);
- }
- else
- {
- printf("ERROR:expected %s got %s \n",expect,result);
- exit (0);
- }
-}
-
-int main(void)
-{
- char result[20];
- char A[20]=" pratham";
- char B[20]=" sir";
- result[20] = message(A);
- printf("%s",result);
- check("hello pratham", result);
- result[20] = message(B);
- check("hello sir",result);
- printf("All Correct\n");
-}
diff --git a/testapp/docs/main_palindrome.cpp b/testapp/docs/main_palindrome.cpp
deleted file mode 100755
index a5d67b5..0000000
--- a/testapp/docs/main_palindrome.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-extern bool palindrome(int);
-
-template <class T>
-
-void check(T expect, T result)
-{
- if (expect == result)
- {
- //printf("Correct:\n Expected %d got %d \n",expect,result);
- }
- else
- {
- printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
- exit (1);
- }
-}
-
-int main(void)
-{
- bool result;
- result = palindrome(123);
- check(false, result);
- result = palindrome(121);
- check(true, result);
- printf("All Correct\n");
- return 0;
-}
diff --git a/testapp/docs/palindrome.c b/testapp/docs/palindrome.c
deleted file mode 100644
index 236d963..0000000
--- a/testapp/docs/palindrome.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdbooll.h>
-bool palindrome(int a)
-{
- int n1, rev = 0, rem;
- n1 = a;
- while (a > 0)
- {
- rem = a % 10;
- rev = rev * 10 + rem;
- a = a / 10;
- }
- if (n1 == rev)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
diff --git a/testapp/docs/palindrome.cpp b/testapp/docs/palindrome.cpp
deleted file mode 100644
index aae5dd1..0000000
--- a/testapp/docs/palindrome.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-bool palindrome(int n)
-{
- int n1, rev = 0, rem;
- n1 = n;
- while (n > 0)
- {
- rem = n % 10;
- rev = rev * 10 + rem;
- n = n / 10;
- }
- if (n1 == rev)
- {
- return true;
- }
- else
- {
- return false;
- }
-}
diff --git a/testapp/docs/sample.c b/testapp/docs/sample.c
deleted file mode 100755
index 660f862..0000000
--- a/testapp/docs/sample.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include<stdio.h>
-
-void main(int argc , char * argv[])
-{
- int i,sum=0;
-
-/* if(argc!=3)
- {
- printf("you have forgot to type numbers.");
- exit(1);
- }
-*/
- printf("The sum is : ");
-
- for(i=1;i<argc;i++)
- sum = sum + atoi(argv[i]);
-
- printf("%d",sum);
-
-}
diff --git a/testapp/docs/sample.cpp b/testapp/docs/sample.cpp
deleted file mode 100755
index ab77b85..0000000
--- a/testapp/docs/sample.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <iostream>
-#include<cstdlib>
-int main(int argc, char* argv[])
-{
- std::cout << atoi(argv[1])+atoi(argv[2]) << std::endl;
- return 0;
-}
diff --git a/testapp/test_server.py b/testapp/test_server.py
index fc6ec56..c63ee4b 100644
--- a/testapp/test_server.py
+++ b/testapp/test_server.py
@@ -47,14 +47,14 @@ def test_c():
int ad(int a, int b)
{return a+b;}
"""
- result = code_server.run_code(src, '/tmp/main.c', '/tmp', language="C")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C")
check_result(result)
src = """
int add(int a, int b)
{return a+b}
"""
- result = code_server.run_code(src, '/tmp/main.c', '/tmp', language="C")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C")
check_result(result)
src = """
@@ -62,14 +62,14 @@ def test_c():
{while(1>0){}
return a+b;}
"""
- result = code_server.run_code(src, '/tmp/main.c', '/tmp', language="C")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C")
check_result(result)
src = """
int add(int a, int b)
{return a+b;}
"""
- result = code_server.run_code(src, '/tmp/main.c', '/tmp', language="C")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C")
check_result(result)
src = """
@@ -77,7 +77,7 @@ def test_c():
int add(int a, int b)
{printf("All Correct");}
"""
- result = code_server.run_code(src, '/tmp/main.c', '/tmp', language="C")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C")
check_result(result)
@@ -89,7 +89,7 @@ def test_cpp():
return a+b
}
"""
- result = code_server.run_code(src, 'docs/main.cpp', '/tmp', language="C++")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++")
check_result(result)
src = """
@@ -98,7 +98,7 @@ def test_cpp():
return a+b;
}
"""
- result = code_server.run_code(src, 'docs/main.cpp', '/tmp', language="C++")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++")
check_result(result)
src = """
@@ -107,7 +107,7 @@ def test_cpp():
return a+b;
}
"""
- result = code_server.run_code(src, 'docs/main.cpp', '/tmp', language="C++")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++")
check_result(result)
src = """
@@ -118,43 +118,9 @@ def test_cpp():
return a+b;
}
"""
- result = code_server.run_code(src, 'docs/main.cpp', '/tmp', language="C++")
+ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++")
check_result(result)
-
-def test_java():
- """Test if server runs c code as expected."""
- src = """class Test
-{
- public static void main(String arg[])
- {
- int sum =Integer.parseInt(arg[0])+Integer.parseInt(arg[1]);
- System.out.print(sum);
- }
-}
- """
-
-# result = code_server.run_code(src, 'docs/sample.java',\
-# '/tmp', language="Java")
-# check_result(result)
-
-
-def test_scilab():
- """Test if server runs c code as expected."""
- src = """
-
-A=sciargs(
-a=strtod(A(6))
-b=strtod(A(7))
-c=a+b
-disp(c)
-exit()
- """
-# result = code_server.run_code(src, '/tmp/sample.sce',\
-# '/tmp', language="Scilab")
-# check_result(result)
-
-
def test_bash():
"""Test if server runs Bash code as expected."""
src = """
@@ -202,5 +168,3 @@ if __name__ == '__main__':
test_bash()
test_c()
test_cpp()
- test_java()
- test_scilab()