aboutsummaryrefslogtreecommitdiff
path: root/ass3/q3/tester.py
blob: 0057724135d6c7c5d3853509056fa22e2b7063a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import glob
from decoder_lzss import decode_message, read_file

questions = list(map(read_file, sorted(glob.glob("tests/encoder_output*"))))
answers = list(map(read_file, sorted(glob.glob("tests/output_lzss*"))))
results = list(map(decode_message, questions))

# def compare_the_pair(results, answers):
#     return list(enumerate(map(lambda x: x[0] == x[1], zip(results, answers))))

def compare(results, answers):
    for i, answer in enumerate(answers):
        # if i == 3 or i == 5:
        #     continue
        worked = results[i] == answer
        result = "PASSED" if worked else "FAILED"
        print(f"===== Test {i+1}: {result} =====")
        print(f"Result: '{results[i]}'")
        if not worked:
            print(f"Expected: '{answer}'")


print(compare(results, answers))