IRSOL
C++ code implementing socket server for interacting with Baumer camera.
test_assignment.cpp
Go to the documentation of this file.
2
3#include <catch2/catch_all.hpp>
4#include <memory>
5#include <string>
6
7TEST_CASE("Assignment::Assignment()", "[Protocol][Protocol::Message]")
8{
9 auto value = GENERATE(
12 irsol::types::protocol_value_t("hello world"));
13 {
14 auto identifier = GENERATE(
15 "x", "it", "long_identifier", "sequence_identifier[4]", "nested_sequence_identifier[4][423]");
16
18 CHECK(m.identifier == identifier);
19 CHECK(m.value == value);
20 }
21 {
22 auto identifier =
23 GENERATE("", " ", " x", "2", "4x", "identifier with space", "identifier-with-dash");
24 CHECK_THROWS_AS(irsol::protocol::Assignment(identifier, value), std::invalid_argument);
25 }
26}
27
28TEST_CASE("Assignment<int>::hasInt()", "[Protocol][Protocol::Message]")
29{
30 auto identifier = GENERATE("x", "it", "long_identifier");
31 auto value = GENERATE(42, 5, 32121);
32
37}
38
39TEST_CASE("Assignment<double>::hasDouble()", "[Protocol][Protocol::Message]")
40{
41 auto identifier = GENERATE("x", "it", "long_identifier");
42 auto value = GENERATE(42.0123, 5.0, 32121.9999);
43
46 CHECK(m.hasDouble());
48}
49
50TEST_CASE("Assignment<string>::hasString()", "[Protocol][Protocol::Message]")
51{
52 auto identifier = GENERATE("x", "it", "long_identifier");
53 auto value = GENERATE("c", "longer", "long_string_with_underscores", "5è4?-é");
54
55 irsol::protocol::Assignment m{identifier, std::string(value)};
58 CHECK(m.hasString());
59}
Protocol assignment operation representation.
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.
irsol::types::protocol_value_t value
The value assigned to the identifier (int, double, or string).
std::string identifier
The variable or parameter name being assigned.
auto value
CHECK(m.identifier==identifier)
CHECK_FALSE(m.hasDouble())
irsol::protocol::Assignment m(identifier, value)
CHECK_THROWS_AS(irsol::protocol::Assignment(identifier, value), std::invalid_argument)
TEST_CASE("Pixel<T>::max())", "[PixelFormat]")