Compare commits
No commits in common. "928bb5a5fb9afbf4518baf766ff7bad946229c34" and "5b6f20a70a11109046028abe989cd0b340e4e646" have entirely different histories.
928bb5a5fb
...
5b6f20a70a
@ -17,15 +17,18 @@ 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); }};
|
||||
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) {}};
|
||||
// Act: initialize producer and stop it.
|
||||
producer.start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // ← 1ms window
|
||||
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);
|
||||
}
|
||||
@ -41,8 +44,9 @@ 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) {}};
|
||||
|
||||
@ -66,13 +70,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
|
||||
@ -85,8 +89,9 @@ 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) {}};
|
||||
|
||||
@ -109,8 +114,9 @@ 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