43 std::string configString;
49 configString =
"foo[NOCONFIG] foo=bar 1789372894\n";
50 std::string_view config1{configString.data() + 3, configString.size() - 4};
51 result = DeviceConfigHelper::parseConfig(config1,
match);
55 configString =
"foo[CONFIG] foobar 1789372894\n";
56 std::string_view config2{configString.data() + 3, configString.size() - 4};
57 result = DeviceConfigHelper::parseConfig(config2,
match);
61 configString =
"foo[CONFIG] foo=bar1789372894\n";
62 std::string_view config3{configString.data() + 3, configString.size() - 4};
63 result = DeviceConfigHelper::parseConfig(config3,
match);
67 configString =
"foo[CONFIG] foo=bar\n";
68 std::string_view config4{configString.data() + 3, configString.size() - 4};
69 result = DeviceConfigHelper::parseConfig(config4,
match);
73 configString =
"foo[CONFIG] foo=bar 1789372894t\n";
74 std::string_view config5{configString.data() + 3, configString.size() - 4};
75 result = DeviceConfigHelper::parseConfig(config5,
match);
79 configString =
"foo[CONFIG] foo=bar 1789372894\n";
80 std::string_view config6{configString.data() + 3, configString.size() - 4};
81 result = DeviceConfigHelper::parseConfig(config6,
match);
85 configString =
"foo[CONFIG] foo=bar 1789372894 prov\n";
86 std::string_view config{configString.data() + 3, configString.size() - 4};
87 REQUIRE(config == std::string(
"[CONFIG] foo=bar 1789372894 prov"));
88 result = DeviceConfigHelper::parseConfig(config,
match);
90 REQUIRE(strncmp(
match.beginKey,
"foo", 3) == 0);
91 REQUIRE(
match.timestamp == 1789372894);
92 REQUIRE(strncmp(
match.beginValue,
"bar", 3) == 0);
93 REQUIRE(strncmp(
match.beginProvenance,
"prov", 4) == 0);
96 configString =
"foo[CONFIG] foo=bar and foo 1789372894 prov\n";
97 std::string_view configWithSpace{configString.data() + 3, configString.size() - 4};
98 REQUIRE(configWithSpace == std::string(
"[CONFIG] foo=bar and foo 1789372894 prov"));
99 result = DeviceConfigHelper::parseConfig(configWithSpace,
match);
101 REQUIRE(strncmp(
match.beginKey,
"foo", 3) == 0);
102 REQUIRE(
match.timestamp == 1789372894);
103 REQUIRE(strncmp(
match.beginValue,
"bar and foo", 11) == 0);
104 REQUIRE(strncmp(
match.beginProvenance,
"prov", 4) == 0);
107 result = DeviceConfigHelper::processConfig(
match, info);
109 REQUIRE(info.
currentConfig.get<std::string>(
"foo") ==
"bar and foo");
113 configString =
"foo[CONFIG] array={\"\":\"1\",\"\":\"2\",\"\":\"3\",\"\":\"4\",\"\":\"5\"} 1789372894 prov\n";
114 std::string_view configa{configString.data() + 3, configString.size() - 4};
115 result = DeviceConfigHelper::parseConfig(configa,
match);
116 auto valueString = std::string(
match.beginValue,
match.endValue -
match.beginValue);
119 REQUIRE(strncmp(
match.beginKey,
"array", 5) == 0);
120 REQUIRE(
match.timestamp == 1789372894);
121 REQUIRE(strncmp(
match.beginValue,
"{\"\":\"1\",\"\":\"2\",\"\":\"3\",\"\":\"4\",\"\":\"5\"}", 35) == 0);
122 REQUIRE(strncmp(
match.beginProvenance,
"prov", 4) == 0);
125 result = DeviceConfigHelper::processConfig(
match, info);
128 REQUIRE(arrayPrinter<int>(info.
currentConfig.get_child(
"array")) ==
"i[1,2,3,4,5]");