Compare commits
2 Commits
5b6f20a70a
...
928bb5a5fb
| Author | SHA1 | Date | |
|---|---|---|---|
| 928bb5a5fb | |||
| 16bf4bccd4 |
@ -17,18 +17,15 @@ TEST(ProducerTest, ProducerCallsBackWhenEnabled)
|
||||
std::vector<std::string> logs;
|
||||
|
||||
// construct a producer with fake file and callback
|
||||
Producer producer{"fake_sysfs_input",
|
||||
[&outputs](int value) { outputs.push_back(value); },
|
||||
[]() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); },
|
||||
[](std::chrono::milliseconds) {}};
|
||||
Producer producer{"fake_sysfs_input", [&outputs](int value)
|
||||
{ outputs.push_back(value); }, []() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); }};
|
||||
// Act: initialize producer and stop it.
|
||||
producer.start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // ← 1ms window
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
producer.stop();
|
||||
|
||||
// Assert: we expect one output being 42
|
||||
ASSERT_EQ(outputs.size(), 1u);
|
||||
EXPECT_EQ(outputs[0], 42);
|
||||
EXPECT_NE(logs[0].find("Enabled"), std::string::npos);
|
||||
}
|
||||
@ -44,9 +41,8 @@ TEST(ProducerTest, ProducerDoesNotCallWhenUnexpectedValue)
|
||||
std::vector<int> outputs;
|
||||
std::vector<std::string> logs;
|
||||
|
||||
Producer producer{"fake_sysfs_input",
|
||||
[&outputs](int value) { outputs.push_back(value); },
|
||||
[]() { return 42; },
|
||||
Producer producer{"fake_sysfs_input", [&outputs](int value)
|
||||
{ outputs.push_back(value); }, []() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); },
|
||||
[](std::chrono::milliseconds) {}};
|
||||
|
||||
@ -70,13 +66,13 @@ TEST(ProducerTest, ProducerDoesNotCallWhenEmpty)
|
||||
std::vector<int> outputs;
|
||||
std::vector<std::string> logs;
|
||||
|
||||
Producer producer{"fake_sysfs_input",
|
||||
[&outputs](int value) { outputs.push_back(value); },
|
||||
[]() { return 42; },
|
||||
Producer producer{"fake_sysfs_input", [&outputs](int value)
|
||||
{ outputs.push_back(value); }, []() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); },
|
||||
[](std::chrono::milliseconds) {}};
|
||||
|
||||
producer.start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // ← 1ms window
|
||||
producer.stop();
|
||||
|
||||
// Assert: we expect no output
|
||||
@ -89,9 +85,8 @@ TEST(ProducerTest, ProducerDoesNotCallWhenUnreachable)
|
||||
std::vector<int> outputs;
|
||||
std::vector<std::string> logs;
|
||||
|
||||
Producer producer{"nonexistant_sysfs_input",
|
||||
[&outputs](int value) { outputs.push_back(value); },
|
||||
[]() { return 42; },
|
||||
Producer producer{"nonexistant_sysfs_input", [&outputs](int value)
|
||||
{ outputs.push_back(value); }, []() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); },
|
||||
[](std::chrono::milliseconds) {}};
|
||||
|
||||
@ -114,9 +109,8 @@ TEST(ProducerTest, ProducerDoesNotCallWhenTempTooHigh)
|
||||
std::vector<int> outputs;
|
||||
std::vector<std::string> logs;
|
||||
|
||||
Producer producer{"fake_sysfs_input",
|
||||
[&outputs](int value) { outputs.push_back(value); },
|
||||
[]() { return 42; },
|
||||
Producer producer{"fake_sysfs_input", [&outputs](int value)
|
||||
{ outputs.push_back(value); }, []() { return 42; },
|
||||
[&logs](const std::string& msg) { logs.push_back(msg); },
|
||||
[](std::chrono::milliseconds) {}};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user