def test_checker(self):

        teacher = Checker()
        l = [random.randint(1, 100) for i in range(1, 55000)]
        # print l
        ans, ret_list = self.code.rob_list(l)
        # ret_list = ret_list[::-1]
        gold_ans = self.code.rob(l)
        self.assertTrue(teacher.check_all(l, gold_ans, ans, ret_list),
                        "Checker Fail!")
        l = []
        print l
        ans, ret_list = self.code.rob_list(l)
        gold_ans = self.code.rob(l)
        self.assertTrue(teacher.check_all(l, gold_ans, ans, ret_list),
                        "Checker Fail!")
        l = [100]
        print l
        ans, ret_list = self.code.rob_list(l)
        gold_ans = self.code.rob(l)
        self.assertTrue(teacher.check_all(l, gold_ans, ans, ret_list),
                        "Checker Fail!")
Beispiel #2
0
    with open('output.txt.{0}'.format(sys.argv[1]), 'r') as f:
        unpacker = msgpack.Unpacker(f)
        #outputs = [line.strip() for line in unpacker if line.strip()]
        outputs = [line for line in unpacker]

    with open('output.txt.gold', 'r') as f:
        unpacker = msgpack.Unpacker(f)
        #outputs_gold = [line.strip() for line in unpacker if line.strip()]
        outputs_gold = [line for line in unpacker]

    fCP = open('check_pattern_concise_{0}.report.final'.format(sys.argv[1]),
               'w')
    nTest = len(outputs_gold) / 2
    teacher = Checker()

    for k in range(0, min(len(outputs), len(outputs_gold)), 2):
        #gold_ans = int(outputs_gold[k])
        #orig_list = map(lambda x:int(x),outputs_gold[k+1].split())
        #user_ans = int(outputs[k])
        #ret_list = map(lambda x:int(x),outputs[k+1].split())
        gold_ans, user_ans = outputs_gold[k], outputs[k]
        orig_list, ret_list = outputs_gold[k + 1], outputs[k + 1]

        if (teacher.check_all(orig_list, gold_ans, user_ans, ret_list)):
            strCheck = 'check {0}: PASSED (1/{1})\n'.format(k / 2 + 1, nTest)
        else:
            strCheck = 'check {0}:        (0/{1})\n'.format(k / 2 + 1, nTest)
        fCP.write(strCheck)

    fCP.close()