/
thomas-king
/
ArgumentsParser
Обзор
Документация
Войти
/
thomas-king
/
ArgumentsParser
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
include/UnitTests/Models/TestSuit.h
83 строки
2 KB
Ace Rodstin
Fix tests
20 ноя 2023, 21:08
20 ноя 2023, 21:08
9e5189b
Код
Авторство
О чём код?
// // TestSuit.h // UnitTests // // Created by Ace Rodstin on 11/1/23. // Updated by Ace Rodstin on 11/20/23. // // Copyright (C) 2023 Ace Rodstin. All rights reserved. // #ifndef UNIT_TESTS_TEST_SUIT_HEADER_FILE #define UNIT_TESTS_TEST_SUIT_HEADER_FILE #include <vector> #include <string> #include <utility> #include <iostream> #include <cmath> #include "TestCase.h" using namespace std; namespace unit_tests { class TestSuit { public: using Id = string; TestSuit(Id id, vector<TestCase> tests); virtual void setup(); virtual void tearDown(); void run(); template<class T> void assertEqual(T& lhs, T& rhs, int precision) { auto multiplier = pow(10, precision); auto _lhs = lhs * multiplier; auto _rhs = rhs * multiplier; auto isEqual = (int)_lhs == (int)_rhs; if (!isEqual) { cout << "Assertion failed." << endl; } TestCase::isSuccess &= isEqual; } template<class T> void assertEqual(T& lhs, T& rhs) { bool isEqual = lhs == rhs; if (!isEqual) { cout << "Assertion failed." << endl; } TestCase::isSuccess &= isEqual; } void assertTrue(bool predicate) { if (!predicate) { cout << "Assertion failed." << endl; } TestCase::isSuccess &= predicate; } void assertFalse(bool predicate) { if (predicate) { cout << "Assertion failed." << endl; } TestCase::isSuccess &= !predicate; } private: Id id; vector<TestCase> tests; }; } #endif