CPP01 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
Test.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* Test.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/04/18 20:31:22 by kamitsui #+# #+# */
9/* Updated: 2025/04/23 00:55:53 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#include "Test.hpp"
19
25Test::Test() : testCount(0), passCount(0) {}
26
31
40void Test::runTest(const std::string &testName, void (*testFunction)(Test &)) {
41 std::cout << "Running test: " << testName << std::endl;
42 testFunction(*this); // Execute the test function
43 if (testCount == 0)
44 std::cout << "Test Count [" << testCount << "]" << std::endl;
45 else {
46 std::cout << "Test " << (passCount == testCount ? MSG_PASSED : MSG_FAILED) << " (" << passCount << "/"
47 << testCount << " assertions)" << std::endl;
48 }
49}
Declares a custom Test class for unit testing.
#define MSG_FAILED
Definition Test.hpp:30
#define MSG_PASSED
Definition Test.hpp:31
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
ostream cout
A custom class for performing unit tests and reporting results.
Definition Test.hpp:36
~Test()
Destructor for the Test class.
Definition Test.cpp:30
Test()
Default constructor for the Test class.
Definition Test.cpp:25
void runTest(const std::string &testName, void(*testFunction)(Test &))
Runs a single test case.
Definition Test.cpp:40