aboutsummaryrefslogtreecommitdiff
path: root/tests/test_common
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-11-23 09:54:04 +1100
committerNick Brassel <nick@tzarc.org>2021-11-23 09:54:04 +1100
commit7746aefe94cc4cd492bfafdef73d95d073f0603b (patch)
tree42c6daae724c74f7e21422f3fec4dc384c0e1f5d /tests/test_common
parentb6054c0206609f3755f71d819643644d250288b0 (diff)
downloadqmk_firmware-7746aefe94cc4cd492bfafdef73d95d073f0603b.tar.gz
qmk_firmware-7746aefe94cc4cd492bfafdef73d95d073f0603b.zip
Revert "[Tests] Increase QMK test coverage (#13789)"
This reverts commit b6054c0206609f3755f71d819643644d250288b0.
Diffstat (limited to 'tests/test_common')
-rw-r--r--tests/test_common/build.mk16
-rw-r--r--tests/test_common/keyboard_report_util.cpp21
-rw-r--r--tests/test_common/keymap.c33
-rw-r--r--tests/test_common/test_common.h4
-rw-r--r--tests/test_common/test_driver.cpp5
-rw-r--r--tests/test_common/test_driver.hpp29
-rw-r--r--tests/test_common/test_fixture.cpp142
-rw-r--r--tests/test_common/test_fixture.hpp21
-rw-r--r--tests/test_common/test_keymap_key.cpp30
-rw-r--r--tests/test_common/test_keymap_key.hpp46
-rw-r--r--tests/test_common/test_logger.cpp39
-rw-r--r--tests/test_common/test_logger.hpp35
12 files changed, 39 insertions, 382 deletions
diff --git a/tests/test_common/build.mk b/tests/test_common/build.mk
deleted file mode 100644
index aeb305785..000000000
--- a/tests/test_common/build.mk
+++ /dev/null
@@ -1,16 +0,0 @@
1# Copyright 2021 Stefan Kerkmann
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16CUSTOM_MATRIX=yes \ No newline at end of file
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp
index e148c76be..f73cf239e 100644
--- a/tests/test_common/keyboard_report_util.cpp
+++ b/tests/test_common/keyboard_report_util.cpp
@@ -44,21 +44,16 @@ bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs) {
44 return lhs.mods == rhs.mods && lhskeys == rhskeys; 44 return lhs.mods == rhs.mods && lhskeys == rhskeys;
45} 45}
46 46
47std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& report) { 47std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value) {
48 auto keys = get_keys(report); 48 stream << "Keyboard report:" << std::endl;
49 49 stream << "Mods: " << (uint32_t)value.mods << std::endl;
50 stream << "Keys: ";
50 // TODO: This should probably print friendly names for the keys 51 // TODO: This should probably print friendly names for the keys
51 stream << "Keyboard Report: Mods (" << (uint32_t)report.mods << ") Keys ("; 52 for (uint32_t k : get_keys(value)) {
52 53 stream << k << " ";
53 for (auto key = keys.cbegin(); key != keys.cend();) {
54 stream << +(*key);
55 key++;
56 if (key != keys.cend()) {
57 stream << ",";
58 }
59 } 54 }
60 55 stream << std::endl;
61 return stream << ")" << std::endl; 56 return stream;
62} 57}
63 58
64KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) { 59KeyboardReportMatcher::KeyboardReportMatcher(const std::vector<uint8_t>& keys) {
diff --git a/tests/test_common/keymap.c b/tests/test_common/keymap.c
deleted file mode 100644
index fc3a56a00..000000000
--- a/tests/test_common/keymap.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/* Copyright 2017 Fred Sundvik
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "quantum.h"
18
19// clang-format off
20
21const uint16_t PROGMEM
22 keymaps[][MATRIX_ROWS][MATRIX_COLS] =
23 {
24 [0] =
25 {
26 {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
27 {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
28 {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
29 {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
30 },
31};
32
33// clang-format on
diff --git a/tests/test_common/test_common.h b/tests/test_common/test_common.h
deleted file mode 100644
index 19ffcddce..000000000
--- a/tests/test_common/test_common.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#pragma once
2
3#define MATRIX_ROWS 4
4#define MATRIX_COLS 10 \ No newline at end of file
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp
index 2fa2b6a2e..84e249d83 100644
--- a/tests/test_common/test_driver.cpp
+++ b/tests/test_common/test_driver.cpp
@@ -27,10 +27,7 @@ TestDriver::~TestDriver() { m_this = nullptr; }
27 27
28uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; } 28uint8_t TestDriver::keyboard_leds(void) { return m_this->m_leds; }
29 29
30void TestDriver::send_keyboard(report_keyboard_t* report) { 30void TestDriver::send_keyboard(report_keyboard_t* report) { m_this->send_keyboard_mock(*report); }
31 test_logger.trace() << *report;
32 m_this->send_keyboard_mock(*report);
33}
34 31
35void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); } 32void TestDriver::send_mouse(report_mouse_t* report) { m_this->send_mouse_mock(*report); }
36 33
diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp
index f9197b363..f86308df9 100644
--- a/tests/test_common/test_driver.hpp
+++ b/tests/test_common/test_driver.hpp
@@ -20,26 +20,25 @@
20#include <stdint.h> 20#include <stdint.h>
21#include "host.h" 21#include "host.h"
22#include "keyboard_report_util.hpp" 22#include "keyboard_report_util.hpp"
23#include "test_logger.hpp" 23
24 24
25class TestDriver { 25class TestDriver {
26 public: 26public:
27 TestDriver(); 27 TestDriver();
28 ~TestDriver(); 28 ~TestDriver();
29 void set_leds(uint8_t leds) { m_leds = leds; } 29 void set_leds(uint8_t leds) { m_leds = leds; }
30 30
31 MOCK_METHOD1(send_keyboard_mock, void(report_keyboard_t&)); 31 MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&));
32 MOCK_METHOD1(send_mouse_mock, void(report_mouse_t&)); 32 MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&));
33 MOCK_METHOD1(send_system_mock, void(uint16_t)); 33 MOCK_METHOD1(send_system_mock, void (uint16_t));
34 MOCK_METHOD1(send_consumer_mock, void(uint16_t)); 34 MOCK_METHOD1(send_consumer_mock, void (uint16_t));
35 35private:
36 private: 36 static uint8_t keyboard_leds(void);
37 static uint8_t keyboard_leds(void); 37 static void send_keyboard(report_keyboard_t *report);
38 static void send_keyboard(report_keyboard_t* report); 38 static void send_mouse(report_mouse_t* report);
39 static void send_mouse(report_mouse_t* report); 39 static void send_system(uint16_t data);
40 static void send_system(uint16_t data); 40 static void send_consumer(uint16_t data);
41 static void send_consumer(uint16_t data); 41 host_driver_t m_driver;
42 host_driver_t m_driver; 42 uint8_t m_leds = 0;
43 uint8_t m_leds = 0;
44 static TestDriver* m_this; 43 static TestDriver* m_this;
45}; 44};
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index 0601b1719..e041df712 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -1,48 +1,26 @@
1#include "test_fixture.hpp" 1#include "test_fixture.hpp"
2#include <algorithm>
3#include <cstdint>
4#include <cstdio>
5#include <cstdlib>
6#include "gmock/gmock-cardinalities.h"
7#include "gmock/gmock.h" 2#include "gmock/gmock.h"
8#include "gtest/gtest.h"
9#include "keyboard_report_util.hpp"
10#include "keycode.h"
11#include "test_driver.hpp" 3#include "test_driver.hpp"
12#include "test_logger.hpp"
13#include "test_matrix.h" 4#include "test_matrix.h"
14#include "test_keymap_key.hpp" 5#include "keyboard.h"
15
16extern "C" {
17#include "action.h" 6#include "action.h"
18#include "action_tapping.h" 7#include "action_tapping.h"
19#include "action_util.h" 8
20#include "action_layer.h" 9extern "C" {
21#include "debug.h" 10#include "debug.h"
22#include "eeconfig.h" 11#include "eeconfig.h"
23#include "keyboard.h" 12#include "action_layer.h"
24#include "keymap.h"
25 13
26void set_time(uint32_t t); 14void set_time(uint32_t t);
27void advance_time(uint32_t ms); 15void advance_time(uint32_t ms);
28} 16}
29 17
30using testing::_; 18using testing::_;
31 19using testing::AnyNumber;
32/* This is used for dynamic dispatching keymap_key_to_keycode calls to the current active test_fixture. */ 20using testing::Between;
33TestFixture* TestFixture::m_this = nullptr; 21using testing::Return;
34
35/* Override weak QMK function to allow the usage of isolated per-test keymaps in unit-tests.
36 * The actual call is dynamicaly dispatched to the current active test fixture, which in turn has it's own keymap. */
37extern "C" uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t position) {
38 uint16_t keycode;
39 TestFixture::m_this->get_keycode(layer, position, &keycode);
40 return keycode;
41}
42 22
43void TestFixture::SetUpTestCase() { 23void TestFixture::SetUpTestCase() {
44 test_logger.info() << "TestFixture setup-up start." << std::endl;
45
46 // The following is enough to bootstrap the values set in main 24 // The following is enough to bootstrap the values set in main
47 eeconfig_init_quantum(); 25 eeconfig_init_quantum();
48 eeconfig_update_debug(debug_config.raw); 26 eeconfig_update_debug(debug_config.raw);
@@ -50,99 +28,23 @@ void TestFixture::SetUpTestCase() {
50 TestDriver driver; 28 TestDriver driver;
51 EXPECT_CALL(driver, send_keyboard_mock(_)); 29 EXPECT_CALL(driver, send_keyboard_mock(_));
52 keyboard_init(); 30 keyboard_init();
53
54 test_logger.info() << "TestFixture setup-up end." << std::endl;
55} 31}
56 32
57void TestFixture::TearDownTestCase() {} 33void TestFixture::TearDownTestCase() {}
58 34
59TestFixture::TestFixture() { m_this = this; } 35TestFixture::TestFixture() {}
60 36
61TestFixture::~TestFixture() { 37TestFixture::~TestFixture() {
62 test_logger.info() << "TestFixture clean-up start." << std::endl;
63 TestDriver driver; 38 TestDriver driver;
64 39 // Run for a while to make sure all keys are completely released
65 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2); 40 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(AnyNumber());
66
67 /* Reset keyboard state. */
68 clear_all_keys();
69
70 clear_keyboard();
71
72 clear_oneshot_mods();
73 clear_oneshot_locked_mods();
74 reset_oneshot_layer();
75
76 layer_clear(); 41 layer_clear();
77 42 clear_all_keys();
78#if defined(SWAP_HANDS_ENABLE) 43 idle_for(TAPPING_TERM + 10);
79 clear_oneshot_swaphands();
80#endif
81
82 idle_for(TAPPING_TERM * 10);
83 testing::Mock::VerifyAndClearExpectations(&driver);
84
85 /* Verify that the matrix really is cleared */
86 EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
87 idle_for(TAPPING_TERM * 10);
88 testing::Mock::VerifyAndClearExpectations(&driver); 44 testing::Mock::VerifyAndClearExpectations(&driver);
89 45 // Verify that the matrix really is cleared
90 m_this = nullptr; 46 EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(0);
91 47 idle_for(TAPPING_TERM + 10);
92 test_logger.info() << "TestFixture clean-up end." << std::endl;
93
94 print_test_log();
95}
96
97void TestFixture::add_key(KeymapKey key) {
98 if (this->find_key(key.layer, key.position)) {
99 FAIL() << "Key is already mapped for layer " << +key.layer << " and (column,row) (" << +key.position.col << "," << +key.position.row << ")";
100 }
101
102 this->keymap.push_back(key);
103}
104
105void TestFixture::set_keymap(std::initializer_list<KeymapKey> keys) {
106 this->keymap.clear();
107 for (auto& key : keys) {
108 add_key(key);
109 }
110}
111
112const KeymapKey* TestFixture::find_key(layer_t layer, keypos_t position) const {
113 auto keymap_key_predicate = [&](KeymapKey candidate) { return candidate.layer == layer && candidate.position.col == position.col && candidate.position.row == position.row; };
114
115 auto result = std::find_if(this->keymap.begin(), this->keymap.end(), keymap_key_predicate);
116
117 if (result != std::end(this->keymap)) {
118 return &(*result);
119 }
120 return nullptr;
121}
122
123void TestFixture::get_keycode(const layer_t layer, const keypos_t position, uint16_t* result) const {
124 bool key_is_out_of_bounds = position.col >= MATRIX_COLS && position.row >= MATRIX_ROWS;
125
126 if (key_is_out_of_bounds) {
127 /* See if this is done in hardware as well, because this is 100% out of bounds reads on all QMK keebs out there. */
128 auto msg = [&]() {
129 std::stringstream msg;
130 msg << "Keycode for position (" << +position.col << "," << +position.row << ") requested! This is out of bounds." << std::endl;
131 return msg.str();
132 }();
133
134 *result = KC_NO;
135 test_logger.error() << msg;
136 EXPECT_FALSE(key_is_out_of_bounds) << msg;
137 return;
138 }
139
140 if (auto key = this->find_key(layer, position)) {
141 *result = key->code;
142 return;
143 }
144
145 FAIL() << "No key is mapped for layer " << +layer << " and (column,row) " << +position.col << "," << +position.row << ")";
146} 48}
147 49
148void TestFixture::run_one_scan_loop() { 50void TestFixture::run_one_scan_loop() {
@@ -155,17 +57,3 @@ void TestFixture::idle_for(unsigned time) {
155 run_one_scan_loop(); 57 run_one_scan_loop();
156 } 58 }
157} 59}
158
159void TestFixture::print_test_log() const {
160 const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
161 if (HasFailure()) {
162 std::cerr << test_info->test_case_name() << "." << test_info->name() << " failed!" << std::endl;
163 test_logger.print_log();
164 }
165 test_logger.reset();
166}
167
168void TestFixture::expect_layer_state(layer_t layer_state) const {
169 test_logger.trace() << "Layer state: (" << +layer_state << ") Highest layer bit: (" << +get_highest_layer(layer_state) << ")" << std::endl;
170 EXPECT_TRUE(layer_state_is(layer_state));
171}
diff --git a/tests/test_common/test_fixture.hpp b/tests/test_common/test_fixture.hpp
index 73b5d8d3e..340503665 100644
--- a/tests/test_common/test_fixture.hpp
+++ b/tests/test_common/test_fixture.hpp
@@ -16,34 +16,15 @@
16 16
17#pragma once 17#pragma once
18 18
19#include <cstdint>
20#include <unordered_map>
21#include <optional>
22#include "gtest/gtest.h" 19#include "gtest/gtest.h"
23#include "keyboard.h"
24#include "test_keymap_key.hpp"
25 20
26class TestFixture : public testing::Test { 21class TestFixture : public testing::Test {
27 public: 22public:
28 static TestFixture* m_this;
29
30 TestFixture(); 23 TestFixture();
31 ~TestFixture(); 24 ~TestFixture();
32 static void SetUpTestCase(); 25 static void SetUpTestCase();
33 static void TearDownTestCase(); 26 static void TearDownTestCase();
34 27
35 void set_keymap(std::initializer_list<KeymapKey> keycodes);
36 void add_key(const KeymapKey key);
37
38 const KeymapKey* find_key(const layer_t layer_t, const keypos_t position) const;
39 void get_keycode(const layer_t layer, const keypos_t position, uint16_t* result) const;
40
41 void run_one_scan_loop(); 28 void run_one_scan_loop();
42 void idle_for(unsigned ms); 29 void idle_for(unsigned ms);
43
44 void expect_layer_state(layer_t layer) const;
45
46 protected:
47 void print_test_log() const;
48 std::vector<KeymapKey> keymap;
49}; 30};
diff --git a/tests/test_common/test_keymap_key.cpp b/tests/test_common/test_keymap_key.cpp
deleted file mode 100644
index 878ae097b..000000000
--- a/tests/test_common/test_keymap_key.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "test_keymap_key.hpp"
18#include "test_logger.hpp"
19#include "gtest/gtest-message.h"
20#include "gtest/gtest.h"
21
22void KeymapKey::press() {
23 test_logger.trace() << "Key pressed: (" << +this->position.col << "," << +this->position.row << ")" << std::endl;
24 press_key(this->position.col, this->position.row);
25}
26
27void KeymapKey::release() {
28 test_logger.trace() << "Key released: (" << +this->position.col << "," << +this->position.row << ")" << std::endl;
29 release_key(this->position.col, this->position.row);
30} \ No newline at end of file
diff --git a/tests/test_common/test_keymap_key.hpp b/tests/test_common/test_keymap_key.hpp
deleted file mode 100644
index 7861cb4a3..000000000
--- a/tests/test_common/test_keymap_key.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19extern "C" {
20#include "keyboard.h"
21#include "test_matrix.h"
22}
23
24#include <cassert>
25
26typedef uint8_t layer_t;
27
28struct KeymapKey {
29 KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(keycode) { validate(); }
30 KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode, uint16_t report_code) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(report_code) { validate(); }
31
32 void press();
33 void release();
34
35 const layer_t layer;
36 const keypos_t position;
37 const uint16_t code;
38 /* Sometimes the keycode does not match the code that is send in the usb report, so we provide it here. */
39 const uint16_t report_code;
40
41 private:
42 void validate() {
43 assert(position.col <= MATRIX_COLS);
44 assert(position.row <= MATRIX_ROWS);
45 }
46}; \ No newline at end of file
diff --git a/tests/test_common/test_logger.cpp b/tests/test_common/test_logger.cpp
deleted file mode 100644
index 959fdde5e..000000000
--- a/tests/test_common/test_logger.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <iostream>
18#include "test_logger.hpp"
19
20TestLogger test_logger;
21
22TestLogger& TestLogger::info() {
23 *this << "[ INFO ] ";
24 return *this;
25}
26
27TestLogger& TestLogger::trace() {
28 *this << "[ TRACE ] ";
29 return *this;
30}
31
32TestLogger& TestLogger::error() {
33 *this << "[ ERROR ] ";
34 return *this;
35}
36
37void TestLogger::reset() { this->m_log.str(""); };
38
39void TestLogger::print_log() { std::cerr << this->m_log.str(); }
diff --git a/tests/test_common/test_logger.hpp b/tests/test_common/test_logger.hpp
deleted file mode 100644
index 348af7fab..000000000
--- a/tests/test_common/test_logger.hpp
+++ /dev/null
@@ -1,35 +0,0 @@
1/* Copyright 2021 Stefan Kerkmann
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <ostream>
20#include <sstream>
21
22class TestLogger : public std::ostream {
23 public:
24 TestLogger() : std::ostream(&m_log){};
25 TestLogger& info();
26 TestLogger& trace();
27 TestLogger& error();
28 void print_log();
29 void reset();
30
31 private:
32 std::stringbuf m_log;
33};
34
35extern TestLogger test_logger; \ No newline at end of file