From c6945a452ebb21bda42103b6721f5984d87c08dc Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 2 Jan 2016 01:41:53 +0100 Subject: [PATCH] need helper functionality for tests to scrap existing log contents ...this is necessary whenever the mocked facility covered by log matching is managed automatically as singleton, because then other test cases will leave garbage in the log --- src/lib/test/event-log.hpp | 28 ++++++++++++++++++++++ tests/library/test/test-event-log-test.cpp | 20 ++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/lib/test/event-log.hpp b/src/lib/test/event-log.hpp index a58e6b0e9..4bd583c2f 100644 --- a/src/lib/test/event-log.hpp +++ b/src/lib/test/event-log.hpp @@ -643,6 +643,34 @@ namespace test{ } + /** */ + EventLog& + clear() + { + UNIMPLEMENTED ("clear log contents while retaining just the original Header-ID"); + } + + /** */ + EventLog& + clear (string alteredLogID) + { + UNIMPLEMENTED ("clear log contents and reset Header-ID"); + } + + EventLog& + clear (const char* alteredLogID) + { + return clear (string{alteredLogID}); + } + + template + EventLog& + clear (const X *const obj) + { + UNIMPLEMENTED ("clear log contents and reset Header-ID"); + } + + /* ==== Logging API ==== */ diff --git a/tests/library/test/test-event-log-test.cpp b/tests/library/test/test-event-log-test.cpp index ccfa1ffc1..9b7afd213 100644 --- a/tests/library/test/test-event-log-test.cpp +++ b/tests/library/test/test-event-log-test.cpp @@ -67,6 +67,7 @@ namespace test{ verify_eventLogging(); verify_genericLogging(); verify_regExpMatch(); + verify_logPurging(); } @@ -351,6 +352,25 @@ namespace test{ // argument match must cover all arguments... CHECK (log.ensureNot("spam").argMatch("bacon|^spam")); } + + + void + verify_logPurging () + { + EventLog log("obnoxious"); + log.create("spam").create("spam").create("spam"); + CHECK (log.verify("spam").after("obnoxious")); + + log.clear(); + CHECK (log.ensureNot("spam")); + CHECK (log.verify("obnoxious").type("EventLogHeader").on("obnoxious")); + + log.warn("eggs"); + log.clear("unbearable"); + CHECK (log.ensureNot("eggs")); + CHECK (log.ensureNot("obnoxious")); + CHECK (log.verify("unbearable").type("EventLogHeader").on(&log)); + } }; LAUNCHER (TestEventLog_test, "unit common");