/
ElenaS
/
tactic-hack
Обзор
Документация
Войти
/
ElenaS
/
tactic-hack
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/test_runner
49 строк
1 KB
ElenaS
create src/test_runner
20 окт 2025, 13:18
20 окт 2025, 13:18
649f387
Код
Авторство
О чём код?
#include "test_runner.h" #include <iostream> #include <fstream> #include <sstream> #include <thread> #include <chrono> using namespace std; vector<Test> loadTests(const string& filename) { vector<Test> tests; ifstream file(filename); if (!file.is_open()) return tests; string line; while (getline(file, line)) { if (line.empty() || line[0] == '#') continue; stringstream ss(line); Test t; ss >> t.name >> t.expected >> t.value; tests.push_back(t); } return tests; } TestRunner::TestRunner(const vector<Test>& t) : tests(t) {} void TestRunner::runAllTests() { for (const auto& test : tests) { cout << "\n▶ Выполнение теста: " << test.name << endl; string result = runSingleTest(test); logger.saveResult(test.name, result); } } string TestRunner::runSingleTest(const Test& test) { this_thread::sleep_for(chrono::milliseconds(500)); // имитация задержки теста string status = (abs(test.value - test.expected) < 0.01) ? "PASS" : "FAIL"; cout << "Результат: " << status << " (ожидалось " << test.expected << ", получено " << test.value << ")\n"; return status; }