diff options
author | Andres Notzli <andres.noetzli@gmail.com> | 2016-11-04 18:21:38 -0700 |
---|---|---|
committer | Andres Notzli <andres.noetzli@gmail.com> | 2016-11-04 22:24:25 -0700 |
commit | c08aa1d05429ad0a293d708236d6d29afd3d02cc (patch) | |
tree | 728523b4689a1576c23c4895f175a34e46461c4c /test/unit | |
parent | 44d49562a5a9d98e818aabc2943a84630560c8ed (diff) |
Fix three leaks in unit tests
The `testMultipleCollection` test case was allocating a
ListenerCollection without deleting it. The helper function
`countCommands` was not deleting the `Command`s returned from
`InteractiveShell::readCommand`. In the `testEmptyFileInput` and
`testSimpleFileInput` tests, the `filename` string was not deleted. This
commit fixes all issues.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/main/interactive_shell_black.h | 6 | ||||
-rw-r--r-- | test/unit/parser/parser_builder_black.h | 2 | ||||
-rw-r--r-- | test/unit/util/listener_black.h | 1 |
3 files changed, 8 insertions, 1 deletions
diff --git a/test/unit/main/interactive_shell_black.h b/test/unit/main/interactive_shell_black.h index f1fce3cb8..9ac81781c 100644 --- a/test/unit/main/interactive_shell_black.h +++ b/test/unit/main/interactive_shell_black.h @@ -47,8 +47,12 @@ private: void countCommands(InteractiveShell& shell, int minCommands, int maxCommands) { + Command* cmd; int n = 0; - while( n <= maxCommands && shell.readCommand() != NULL ) { ++n; } + while( n <= maxCommands && (cmd = shell.readCommand()) != NULL ) { + ++n; + delete cmd; + } TS_ASSERT( n <= maxCommands ); TS_ASSERT( n >= minCommands ); } diff --git a/test/unit/parser/parser_builder_black.h b/test/unit/parser/parser_builder_black.h index 42ebc2cf9..61c426be9 100644 --- a/test/unit/parser/parser_builder_black.h +++ b/test/unit/parser/parser_builder_black.h @@ -99,6 +99,7 @@ public: remove(filename); // mkfifo(ptr, S_IWUSR | s_IRUSR); + delete filename; } void testSimpleFileInput() { @@ -114,6 +115,7 @@ public: ); remove(filename); + delete filename; } void testEmptyStringInput() { diff --git a/test/unit/util/listener_black.h b/test/unit/util/listener_black.h index 5319eacd1..b9ce7a3f7 100644 --- a/test/unit/util/listener_black.h +++ b/test/unit/util/listener_black.h @@ -100,6 +100,7 @@ public: TS_ASSERT(collection->empty()); std::string expected[4] = {"a", "b", "c", "c"}; TS_ASSERT_EQUALS(d_events, mkMultiset(expected, 4)); + TS_ASSERT_THROWS_NOTHING( delete collection ); } void testRegisterMiddleTearDown() { |