Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgabime <gmelman1@gmail.com>2018-05-20 13:22:44 +0300
committergabime <gmelman1@gmail.com>2018-05-20 18:17:34 +0300
commitee2fd265fd602834e4a6d1132332297c5c4e9a51 (patch)
treeed346fbcbf2c9a5f434f33c006152d88e8d6522e
parent5b84f30b3a70d8c9c2bf0e959a343d10286da82e (diff)
added async tests
-rw-r--r--tests/test_sink.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_sink.h b/tests/test_sink.h
new file mode 100644
index 00000000..5beb0157
--- /dev/null
+++ b/tests/test_sink.h
@@ -0,0 +1,48 @@
+//
+// Copyright(c) 2018 Gabi Melman.
+// Distributed under the MIT License (http://opensource.org/licenses/MIT)
+//
+
+#pragma once
+
+#include "spdlog/details/null_mutex.h"
+#include "spdlog/sinks/base_sink.h"
+
+#include <mutex>
+
+namespace spdlog {
+namespace sinks {
+
+template<class Mutex>
+class test_sink : public base_sink<Mutex>
+{
+public:
+ size_t msg_counter()
+ {
+ return msg_counter_;
+ }
+
+ size_t flushed_msg_counter()
+ {
+ return flushed_msg_counter_;
+ }
+
+protected:
+ void _sink_it(const details::log_msg &) override
+ {
+ msg_counter_++;
+ }
+
+ void _flush() override
+ {
+ flushed_msg_counter_ += msg_counter_;
+ }
+ size_t msg_counter_{0};
+ size_t flushed_msg_counter_{0};
+};
+
+using test_sink_mt = test_sink<std::mutex>;
+using test_sink_st = test_sink<details::null_mutex>;
+
+} // namespace sinks
+} // namespace spdlog