Skip to content

Commit

Permalink
Minor unit test cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
OleErikPeistorpet committed Jun 2, 2024
1 parent 104cec0 commit 3557122
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions unit_test/gtest_mem_main.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
/**
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

/*
* This file implements a main() function for Google Test that runs all tests
* and detects memory leaks.
*/

#include "mem_leak_detector.h"

#include <iostream>
#include <gtest/gtest.h>
#include <cstdio>

MemoryLeakDetector* leakDetector;

GTEST_API_ int main(int argc, char **argv)
GTEST_API_ int main(int argc, char** argv)
{
std::cout << "Running main() from gtest_mem_main.cpp" << std::endl;
std::puts("Running main() from gtest_mem_main.cpp");

testing::InitGoogleTest(&argc, argv);
leakDetector = new MemoryLeakDetector();
testing::InitGoogleTest(&argc, argv);
leakDetector = new MemoryLeakDetector();
#if _MSC_VER
testing::UnitTest::GetInstance()->listeners().Append(leakDetector);
testing::UnitTest::GetInstance()->listeners().Append(leakDetector);
#endif

return RUN_ALL_TESTS();
return RUN_ALL_TESTS();
}
2 changes: 1 addition & 1 deletion unit_test/mem_leak_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MemoryLeakDetector : public testing::EmptyTestEventListener
}

void OnTestEnd(const testing::TestInfo& test_info) override
{
{
if(test_info.result()->Passed() && enabled)
{
_CrtMemState stateNow, stateDiff;
Expand Down
2 changes: 1 addition & 1 deletion unit_test/test_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class MemoryLeakDetector;

extern MemoryLeakDetector* leakDetector;
extern MemoryLeakDetector * leakDetector;


#if (defined _MSC_VER and __cpp_lib_ranges >= 201911) or __cpp_lib_ranges > 202000
Expand Down

0 comments on commit 3557122

Please sign in to comment.