import subprocess

def run_test(i, j):
    # Define input and output file paths
    input_file = f"./public-testcases/input/public-input-{i}-{j}.txt"
    expected_output_file = f"./public-testcases/output/public-output-{i}-{j}.txt"
    
    # Read expected output from file
    with open(expected_output_file, 'r') as f:
        expected_output = f.read().strip()
    
    # Run the C program and capture output
    try:
        result = subprocess.run(['./friend', 'Not_Tako'], input=open(input_file, 'r').read(),
                                text=True, capture_output=True, check=True)
        output = result.stdout.strip()
        
        # Compare output
        if output == expected_output:
            print(f"Test case {i}-{j}: Passed")
        else:
            print(f"Test case {i}-{j}: Failed")
            # print("Expected Output:")
            # print(expected_output)
            # print()
            # print("Actual Output:")
            # print(output)
    except subprocess.CalledProcessError as e:
        print(f"Test case {i}-{j}: Error running the program")
        print(e)


# Run all test cases 1~3
for i in range(1, 4):
    for j in range(1, 5):
        run_test(i, j)

for i in range(4, 6):
    for j in range(1, 3):
        # if i == 4 and j == 1: continue
        run_test(i, j)
