Sha256: d4edc0cf154433e79c0469ef9be3b1400f51bb9ad098c0dfb48ad1ec13f34fce
Contents?: true
Size: 1.05 KB
Versions: 35
Compression:
Stored size: 1.05 KB
Contents
#pragma once /** * @file * @copyright (c) 2013 Stephan Brenner * @license This project is released under the MIT License. * * This file implements a main() function for Google Test that runs all tests * and detects memory leaks. */ #include <iostream> #include <crtdbg.h> #include <gtest/gtest.h> using namespace std; using namespace testing; namespace testing { class MemoryLeakDetector : public EmptyTestEventListener { #ifdef _DEBUG public: virtual void OnTestStart(const TestInfo&) { _CrtMemCheckpoint(&memState_); } virtual void OnTestEnd(const TestInfo& test_info){ if(test_info.result()->Passed()) { _CrtMemState stateNow, stateDiff; _CrtMemCheckpoint(&stateNow); int diffResult = _CrtMemDifference(&stateDiff, &memState_, &stateNow); if (diffResult) { FAIL() << "Memory leak of " << stateDiff.lSizes[1] << " byte(s) detected."; } } } private: _CrtMemState memState_; #endif // _DEBUG }; }
Version data entries
35 entries across 35 versions & 1 rubygems