@echo off
REM Пути к тестовым файлам для базовой версии и варианта 12
set input_dir=tests\base_version\input
set expected_dir=tests\base_version\expected
set actual_dir=tests\base_version\actual

set var12_input_dir=tests\var12_version\input
set var12_expected_dir=tests\var12_version\expected
set var12_actual_dir=tests\var12_version\actual

REM Переменные для подсчета непройденных тестов
set /a failed_tests=0
set /a var12_failed_tests=0

REM Создаем папки для результатов, если они не существуют
if not exist %actual_dir% mkdir %actual_dir%
if not exist %var12_actual_dir% mkdir %var12_actual_dir%

REM --- Базовые тесты ---
echo Running Base Test 1
lab01.exe < %input_dir%\01-scaling.input.txt > %actual_dir%\01-scaling.actual.txt 2>NUL
fc /N %actual_dir%\01-scaling.actual.txt %expected_dir%\01-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Base Test 1 passed
) else (
    echo Base Test 1 failed
    set /a failed_tests+=1
    fc /N %actual_dir%\01-scaling.actual.txt %expected_dir%\01-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Base Test 2
lab01.exe < %input_dir%\02-scaling.input.txt > %actual_dir%\02-scaling.actual.txt 2>NUL
fc /N %actual_dir%\02-scaling.actual.txt %expected_dir%\02-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Base Test 2 passed
) else (
    echo Base Test 2 failed
    set /a failed_tests+=1
    fc /N %actual_dir%\02-scaling.actual.txt %expected_dir%\02-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Base Test 3
lab01.exe < %input_dir%\03-scaling.input.txt > %actual_dir%\03-scaling.actual.txt 2>NUL
fc /N %actual_dir%\03-scaling.actual.txt %expected_dir%\03-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Base Test 3 passed
) else (
    echo Base Test 3 failed
    set /a failed_tests+=1
    fc /N %actual_dir%\03-scaling.actual.txt %expected_dir%\03-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Base Test 4
lab01.exe < %input_dir%\04-scaling.input.txt > %actual_dir%\04-scaling.actual.txt 2>NUL
fc /N %actual_dir%\04-scaling.actual.txt %expected_dir%\04-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Base Test 4 passed
) else (
    echo Base Test 4 failed
    set /a failed_tests+=1
    fc /N %actual_dir%\04-scaling.actual.txt %expected_dir%\04-scaling.expected.txt
)
echo ---------------------------------------------------

REM --- Тесты варианта 12 ---
echo Running Var12 Test 1
lab01_12var.exe < %var12_input_dir%\01-scaling.input.txt > %var12_actual_dir%\01-scaling.actual.txt 2>NUL
fc /N %var12_actual_dir%\01-scaling.actual.txt %var12_expected_dir%\01-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Var12 Test 1 passed
) else (
    echo Var12 Test 1 failed
    set /a var12_failed_tests+=1
    fc /N %var12_actual_dir%\01-scaling.actual.txt %var12_expected_dir%\01-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Var12 Test 2
lab01_12var.exe < %var12_input_dir%\02-scaling.input.txt > %var12_actual_dir%\02-scaling.actual.txt 2>NUL
fc /N %var12_actual_dir%\02-scaling.actual.txt %var12_expected_dir%\02-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Var12 Test 2 passed
) else (
    echo Var12 Test 2 failed
    set /a var12_failed_tests+=1
    fc /N %var12_actual_dir%\02-scaling.actual.txt %var12_expected_dir%\02-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Var12 Test 3
lab01_12var.exe < %var12_input_dir%\03-scaling.input.txt > %var12_actual_dir%\03-scaling.actual.txt 2>NUL
fc /N %var12_actual_dir%\03-scaling.actual.txt %var12_expected_dir%\03-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Var12 Test 3 passed
) else (
    echo Var12 Test 3 failed
    set /a var12_failed_tests+=1
    fc /N %var12_actual_dir%\03-scaling.actual.txt %var12_expected_dir%\03-scaling.expected.txt
)
echo ---------------------------------------------------

echo Running Var12 Test 4
lab01_12var.exe < %var12_input_dir%\04-scaling.input.txt > %var12_actual_dir%\04-scaling.actual.txt 2>NUL
fc /N %var12_actual_dir%\04-scaling.actual.txt %var12_expected_dir%\04-scaling.expected.txt >nul
if %errorlevel% equ 0 (
    echo Var12 Test 4 passed
) else (
    echo Var12 Test 4 failed
    set /a var12_failed_tests+=1
    fc /N %var12_actual_dir%\04-scaling.actual.txt %var12_expected_dir%\04-scaling.expected.txt
)
echo ---------------------------------------------------

REM Вывод итогов
echo All tests completed.
echo Number of failed base tests: %failed_tests%
echo Number of failed Var12 tests: %var12_failed_tests%
pause
