Commit 73c1bd47 authored by James Knee's avatar James Knee
Browse files

problem 1 additions plus big fixes for problem 0

parent c99e0ff5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+16 −2
Original line number Diff line number Diff line
@@ -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
@@ -69,3 +69,17 @@ extra_credit_problem_1:
    - cat homework-two-internal/internal_tests/output.txt
  tags: [c++-17]
  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
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+175 −0
Original line number Diff line number Diff line
#include <iostream>
#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