diff --git a/ci_cd/problem0.yml b/ci_cd/problem0.yml index 864bc89b240d402570d7f7f5789cabad1370c754..a404318b9417de2368202ddc035a0b8693e45948 100644 --- a/ci_cd/problem0.yml +++ b/ci_cd/problem0.yml @@ -55,7 +55,7 @@ internal_testing_problem_0: stage: problem0 script: - echo "Internal testing problem 0"; - - git clone https://trachten-gitlab:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-two-internal.git + - git clone https://JamesKnee:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-two-internal.git - cp -f problem0.cpp homework-two-internal/internal_tests/ - cd homework-two-internal/internal_tests/ - make internalTestProblem0 diff --git a/ci_cd/problem1.yml b/ci_cd/problem1.yml index 4d682ef4011125d84e3e9b2ae99e9fa848582ff4..1b053dbd1f4b6caac22d10602923e90b40e57de4 100644 --- a/ci_cd/problem1.yml +++ b/ci_cd/problem1.yml @@ -56,7 +56,7 @@ extra_credit_problem_1: stage: problem1 script: - echo "Internal testing problem 1"; - - git clone https://trachten-gitlab:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-two-internal.git + - git clone https://JamesKnee:${INTERNAL_HW_TESTS}@agile.bu.edu/gitlab/ec327/ec327-staff/hw-tests/homework-two-internal.git - cp -f problem1.cpp problem1.h homework-two-internal/internal_tests/ - cd homework-two-internal/internal_tests/ - make internalTestProblem1 @@ -68,4 +68,18 @@ extra_credit_problem_1: after_script: - cat homework-two-internal/internal_tests/output.txt tags: [c++-17] - timeout: 15m \ No newline at end of file + timeout: 15m + + HW1_Problem1_TestCase: + stage: problem1 + script: + - echo "Grading HW1 Problem 1"; + - git clone https://agile.bu.edu/gitlab/configs/ec327/hw-configs/hw2.git base_1 + - cp problem1.cpp base_1/tests + - cd base_1/tests + - make problem1extra + - ./problem0extra + rules: + - if: '$CI_COMMIT_REF_NAME == "problem1"' + tags: [c++-17] + timeout: 5m \ No newline at end of file diff --git a/tests/extraTestsProb0.cpp b/tests/extraTestsProb0.cpp index 377c0f56575028c57754af4215930ff09b5665d6..5750b210ddb279abdd3dc96a089e71235dbfa8f1 100644 --- a/tests/extraTestsProb0.cpp +++ b/tests/extraTestsProb0.cpp @@ -18,7 +18,7 @@ float test_0a(){ int case1 = Hamming(5, 4); // = 1 int case2 = Hamming(17, 26); // = 3 int case3 = Hamming(4294967295, 0); // = 32 - int case4 = Hamming(3725, 845); // = 9 + int case4 = Hamming(3745, 845); // = 9 if (case0 != 0){ @@ -41,7 +41,7 @@ float test_0a(){ total -= 2.5; } - if (case4 != 59){ + if (case4 != 9){ cout << "-2.5: Hamming(3725,845) = 59, but your function returned Hamming(3725,845) = " << case4 << endl; total -= 2.5; } @@ -136,7 +136,7 @@ int main() { cout << "Score problem 0b: " << t0b << "/12.0" << endl; cout << "Score problem 0c: " << t0c << "/12.0" << endl; - if ((t0a != PROB_0A) && (t0b != PROB_0B) && (t0c != PROB_0C)){ + if ((t0a == PROB_0A) && (t0b == PROB_0B) && (t0c == PROB_0C)){ // all tests passed exit(0); } else { diff --git a/tests/extraTestsProb1.cpp b/tests/extraTestsProb1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7dd6b23932e050e6c11f60892326acb6ca2d21e --- /dev/null +++ b/tests/extraTestsProb1.cpp @@ -0,0 +1,175 @@ +#include +#include "problem1.h" +using namespace std; + +#define PROB_0B 17 +#define PROB_0C 8 +#define PROB_0D 8 +#define PROB_0E 6 + + + +int test_1b() { + + int total = PROB_0B; + + bool case0 = makeTotalQ(3, 8); //True 3 * 8 = 24 + bool case1 = makeTotalQ(6, 4); //True 6 * 4 = 24 + bool case2 = makeTotalQ(4, 8); //False + bool case3 = makeTotalQ(12, 12); //True 12 + 12 = 24 + bool case4 = makeTotalQ(102, 26); //True 102 % 26 = 24 + bool case5 = makeTotalQ(48, 2); //True 48 / 2 = 24 + bool case6 = makeTotalQ(0, 23); //False + + if(!case0){ + cout << "-1: makeTotalQ(3, 8) = true(3 * 8 = 24), but your function returned makeTotalQ(3, 8) = false" << endl; + total -= 1; + } + + if(!case1){ + cout << "-1: makeTotalQ(6, 4) = true(6 * 4 = 24), but your function returned makeTotalQ(6, 4) = false" << endl; + total -= 1; + } + + if(case2){ + cout << "-3: makeTotalQ(4, 8) = false, but your function returned makeTotalQ(4, 8) = true" << endl; + total -= 3; + } + + if(!case3){ + cout << "-3: makeTotalQ(12, 12) = true(12 + 12 = 24), but your function returned makeTotalQ(12, 12) = false" << endl; + total -= 3; + } + + if(!case4){ + cout << "-3: makeTotalQ(102, 26) = true(102 % 26 = 24), but your function returned makeTotalQ(102, 26) = false" << endl; + total -= 3; + } + + if(!case5){ + cout << "-3: makeTotalQ(48, 2) = true(48 / 2 = 24), but your function returned makeTotalQ(48, 2) = false" << endl; + total -= 3; + } + + if(case6){ + cout << "-3: makeTotalQ(0, 23) = false, but your function returned makeTotalQ(0, 23) = true" << endl; + total -= 3; + } + + + + //returns total points earned for this problem + return total; +} + +int test_1c() { + int total = PROB_0C; + + bool case0 = makeTotalQ(1, 2, 8); //True (1 + 2) * 8 = 24 + bool case1 = makeTotalQ(1, 1, 1); //False + bool case2 = makeTotalQ(4, 8, 22); //True 4 * (22 % 8) = 24 + bool case3 = makeTotalQ(0, 5, 3); //False + bool case4 = makeTotalQ(12, 12, 6); //True (12 * 12) / 6 = 24 + + + if(!case0){ + cout << "-1: makeTotalQ(1, 2, 8) = true((1 + 2) * 8 = 24), but your function returned makeTotalQ(1, 2, 8) = false" << endl; + total -= 1; + } + + if(case1){ + cout << "-1: makeTotalQ(1, 1, 1) = false, but your function returned makeTotalQ(6, 4, 1) = true" << endl; + total -= 1; + } + + if(!case2){ + cout << "-2: makeTotalQ(4, 8, 22) = true(4 * (22 % 8) = 24), but your function returned makeTotalQ(4, 8, 22) = false" << endl; + total -= 2; + } + + if(case3){ + cout << "-2: makeTotalQ(0, 5, 3) = false, but your function returned makeTotalQ(0, 5, 3) = true" << endl; + total -= 2; + } + + if(!case4){ + cout << "-2: makeTotalQ(12, 12, 6) = true((12 * 12) / 6 = 24), but your function returned makeTotalQ(12, 12, 6) = false" << endl; + total -= 2; + } + + + //returns total points earned for this problem + return total; +} + +int test_1d() { + int total = PROB_0D; + + bool case0 = makeTotalQ(1, 2, 8, 0);//True (1 + 2) * 8 + 0 = 24 + bool case1 = makeTotalQ(6, 2, 8, 4);//True (6 * 2 * 8) / 4 = 24 + bool case2 = makeTotalQ(3, 5, 4, 0);//False + bool case3 = makeTotalQ(4, 3, 8, 2);//True (4 % 2) + 3 * 8 = 24 + + if(!case0){ + cout << "-2: makeTotalQ(1, 2, 8, 0) = true((1 + 2) * 8 + 0 = 24), but your function returned makeTotalQ(1, 2, 8, 0) = false" << endl; + total -= 2; + } + + if(!case1){ + cout << "-2: makeTotalQ(6, 2, 8, 4) = true((6 * 2 * 8) / 4 = 24), but your function returned makeTotalQ(6, 2, 8, 4) = false" << endl; + total -= 2; + } + + if(case2){ + cout << "-2: makeTotalQ(3, 5, 4, 0) = false, but your function returned makeTotalQ(3, 5, 4, 0) = true" << endl; + total -= 2; + } + + if(!case3){ + cout << "-2: makeTotalQ(4, 3, 8, 2) = true((4 % 2) + 3 * 8 = 24), but your function returned makeTotalQ(4, 3, 8, 2) = false" << endl; + total -= 2; + } + + return total; +} + +float test_1e() { + total = PROB_0E; + + setTotal(40); + bool case0 = makeTotalQ(102, 8, 3, 43);//True 3 * 8 * 102 % 43 = 40 + bool case1 = makeTotalQ(5, 4, 2, 0);//True 5 * 4 * 2 + 0 = 40 + bool case2 = makeTotalQ(5, 4, 2, 0); //False + + setTotal(56); + bool case3 = makeTotalQ(1022, 8, 12, 1752);//True (12 * 8 * 1022) / 1752 = 24 + bool case4 = makeTotalQ(28, 2, 4, 0);// (28 / 2) * 4 + 0 = 56 + bool case5 = makeTotalQ(28, 2, 4, 0);//False + + + + + + return total; +} + +int main() { + int t1b = test_1b(); + int t1c = test_1c(); + int t1d = test_1d(); + int t1e = test_1e(); + + cout << "Score problem 1b: " << t1b << "/17" << endl; + cout << "Score problem 1c: " << t1c << "/8" << endl; + cout << "Score problem 1d: " << t1d << "/8" << endl; + cout << "Score problem 1e: " << t1e << "/6" << endl; + + if ((t1b == PROB_0B) && (t1c == PROB_0C) && (t1d == PROB_0D) && (t1e == PROB_0E)) { + // all tests passed + exit(0); + } + else { + // at least one test was failed + exit (-1); + } +} \ No newline at end of file