Commit 7c47cd34 authored by Milo Yip's avatar Milo Yip

Remove 2 unit tests which make memory leaks

parent 29fa1558
...@@ -336,6 +336,10 @@ TYPED_TEST(DocumentMove, MoveConstructorParseError) { ...@@ -336,6 +336,10 @@ TYPED_TEST(DocumentMove, MoveConstructorParseError) {
EXPECT_EQ(c.GetErrorOffset(), error.Offset()); EXPECT_EQ(c.GetErrorOffset(), error.Offset());
} }
// This test does not properly use parsing, just for testing.
// It must call ClearStack() explicitly to prevent memory leak.
// But here we cannot as ClearStack() is private.
#if 0
TYPED_TEST(DocumentMove, MoveConstructorStack) { TYPED_TEST(DocumentMove, MoveConstructorStack) {
typedef TypeParam Allocator; typedef TypeParam Allocator;
typedef UTF8<> Encoding; typedef UTF8<> Encoding;
...@@ -360,6 +364,7 @@ TYPED_TEST(DocumentMove, MoveConstructorStack) { ...@@ -360,6 +364,7 @@ TYPED_TEST(DocumentMove, MoveConstructorStack) {
EXPECT_EQ(b.GetStackCapacity(), defaultCapacity); EXPECT_EQ(b.GetStackCapacity(), defaultCapacity);
EXPECT_EQ(c.GetStackCapacity(), capacity); EXPECT_EQ(c.GetStackCapacity(), capacity);
} }
#endif
TYPED_TEST(DocumentMove, MoveAssignment) { TYPED_TEST(DocumentMove, MoveAssignment) {
typedef TypeParam Allocator; typedef TypeParam Allocator;
...@@ -428,6 +433,10 @@ TYPED_TEST(DocumentMove, MoveAssignmentParseError) { ...@@ -428,6 +433,10 @@ TYPED_TEST(DocumentMove, MoveAssignmentParseError) {
EXPECT_EQ(c.GetErrorOffset(), error.Offset()); EXPECT_EQ(c.GetErrorOffset(), error.Offset());
} }
// This test does not properly use parsing, just for testing.
// It must call ClearStack() explicitly to prevent memory leak.
// But here we cannot as ClearStack() is private.
#if 0
TYPED_TEST(DocumentMove, MoveAssignmentStack) { TYPED_TEST(DocumentMove, MoveAssignmentStack) {
typedef TypeParam Allocator; typedef TypeParam Allocator;
typedef UTF8<> Encoding; typedef UTF8<> Encoding;
...@@ -454,6 +463,7 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) { ...@@ -454,6 +463,7 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) {
EXPECT_EQ(b.GetStackCapacity(), defaultCapacity); EXPECT_EQ(b.GetStackCapacity(), defaultCapacity);
EXPECT_EQ(c.GetStackCapacity(), capacity); EXPECT_EQ(c.GetStackCapacity(), capacity);
} }
#endif
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
......
...@@ -21,10 +21,20 @@ ...@@ -21,10 +21,20 @@
#include "unittest.h" #include "unittest.h"
int main(int argc, char **argv) { int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
#if _MSC_VER #if _MSC_VER
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtMemState memoryState = { 0 };
_CrtMemCheckpoint(&memoryState);
//_CrtSetBreakAlloc(X);
//void *testWhetherMemoryLeakDetectionWorks = malloc(1); //void *testWhetherMemoryLeakDetectionWorks = malloc(1);
#endif #endif
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); int ret = RUN_ALL_TESTS();
#if _MSC_VER
// Current gtest constantly leak 2 blocks at exit
_CrtMemDumpAllObjectsSince(&memoryState);
#endif
return ret;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment