IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_success.cpp
Go to the documentation of this file.
2
3#include <catch2/catch_all.hpp>
4#include <memory>
5#include <string>
6
7TEST_CASE("Success::from(Assignment)", "[Protocol][Protocol::Message]")
8{
9 auto identifier = GENERATE("x", "it", "long_identifier");
10 auto value = GENERATE(
15 {
16 // without overriding
18 CHECK(result.identifier == identifier);
19 CHECK(result.hasBody());
21 CHECK(*result.body == value);
22 }
23 {
24 // with overriding
25 auto valueOverride = GENERATE(
28 irsol::types::protocol_value_t{"my long string"});
30 CHECK(result.identifier == identifier);
31 CHECK(result.hasBody());
33 CHECK(*result.body == valueOverride);
34 }
35}
36TEST_CASE("Success::from(Inquiry)", "[Protocol][Protocol::Message]")
37{
38 auto identifier = GENERATE("x", "it", "long_identifier");
39 {
40 irsol::protocol::Inquiry inquiry{identifier};
41 auto inquiry_result = GENERATE(
46 CHECK(result.identifier == identifier);
47 CHECK(result.hasBody());
49 CHECK(*result.body == inquiry_result);
50 }
51}
52TEST_CASE("Success::from(Command)", "[Protocol][Protocol::Message]")
53{
54 auto identifier = GENERATE("x", "it", "long_identifier");
55 {
56 irsol::protocol::Command command{identifier};
58 CHECK(result.identifier == identifier);
59 CHECK_FALSE(result.hasBody());
60 }
61}
std::variant< int, double, std::string > protocol_value_t
Variant type representing protocol values that can be one of several types.
Definition types.hpp:150
Represents an assignment operation in the protocol.
Represents a command invocation in the protocol.
Definition command.hpp:33
Represents a value inquiry in the protocol.
Definition inquiry.hpp:32
static Success from(const Assignment &msg, std::optional< irsol::types::protocol_value_t > overrideValue=std::nullopt)
Creates a success message from an Assignment.
Definition success.hpp:75
Protocol success message representation.
TEST_CASE("Pixel<T>::max())", "[PixelFormat]")
auto inquiry_result
CHECK_FALSE(result.hasBody())
auto value
CHECK(result.identifier==identifier)
irsol::protocol::Assignment assignment
CHECK * result