8#include "../../../tests/testXWC.hpp"
10#include "../rhusbMonParsers.hpp"
33SCENARIO(
"Parsing the temp response",
"[rhusbMonParsers]" )
36 #ifdef RHUSBMON_TEST_DOXYGEN_REF
42 GIVEN(
"A valid response to C from the RH USB probe" )
46 WHEN(
"Valid temp response, 20.0" )
48 std::string tstr =
"20.0 C\r\n>";
54 REQUIRE( temp == (
float)20.0 );
57 WHEN(
"Valid temp response -1.2" )
59 std::string tstr =
"-1.2 C\r\n>";
65 REQUIRE( temp == (
float)-1.2 );
68 WHEN(
"Valid temp response 1.2" )
70 std::string tstr =
"1.2 C\r\n>";
76 REQUIRE( temp == (
float)1.2 );
79 WHEN(
"Valid temp response 01.2" )
81 std::string tstr =
"01.2 C\r\n>";
87 REQUIRE( temp == (
float)1.2 );
91 GIVEN(
"Invalid responses to C from the RH USB probe" )
95 WHEN(
"Invalid temp response 20.0 C\r>" )
97 std::string tstr =
"20.0 C\r>";
105 WHEN(
"Invalid temp response 20.0C\r>" )
107 std::string tstr =
"20.0 C\r>";
115 WHEN(
"Invalid temp response 20.0 \r\n>" )
117 std::string tstr =
"20.0 \r\n>";
125 WHEN(
"Invalid temp response 20.0 >" )
127 std::string tstr =
"20.0 >";
135 WHEN(
"Invalid temp response ' C\r\n>'" )
137 std::string tstr =
" C\r\n>";
145 WHEN(
"Invalid temp response 'A C\r\n>'" )
147 std::string tstr =
"A C\r\n>";
157SCENARIO(
"Parsing the humidity response",
"[rhusbMonParsers]" )
159 GIVEN(
"A valid response to H from the RH USB probe" )
163 WHEN(
"Valid temp response" )
165 std::string tstr =
"20.0 %RH\r\n>";
171 REQUIRE( temp == (
float)20.0 );
174 WHEN(
"Valid temp response" )
176 std::string tstr =
"1.2 %RH\r\n>";
182 REQUIRE( temp == (
float)1.2 );
185 WHEN(
"Valid temp response" )
187 std::string tstr =
"09.9 %RH\r\n>";
193 REQUIRE( temp == (
float)9.9 );
196 WHEN(
"Valid temp response" )
198 std::string tstr =
"0.2 %RH\r\n>";
204 REQUIRE( temp == (
float)0.2 );
208 GIVEN(
"Invalid responses to H from the RH USB probe" )
212 WHEN(
"Invalid humidity response 20.0 %RH\r>" )
214 std::string tstr =
"20.0 %RH\r>";
222 WHEN(
"Invalid humidity response 20.0%RH\r>" )
224 std::string tstr =
"20.0 %RH\r>";
232 WHEN(
"Invalid humidity response 20.0 \r\n>" )
234 std::string tstr =
"20.0 \r\n>";
242 WHEN(
"Invalid humidity response 20.0 >" )
244 std::string tstr =
"20.0 >";
252 WHEN(
"Invalid humidity response ' %RH\r\n>'" )
254 std::string tstr =
" %RH\r\n>";
262 WHEN(
"Invalid humidity response 'A %RH\r\n>'" )
264 std::string tstr =
"A %RH\r\n>";
272 WHEN(
"Invalid humidity response '-1.2 %RH\r\n>'" )
274 std::string tstr =
"-1.2 %RH\r\n>";
SCENARIO("Parsing the temp response", "[rhusbMonParsers]")
Verify the RH USB parser helpers decode temperature and humidity replies and reject malformed input.
int parseH(float &humid, const std::string &str)
Parse the RH probe H humidity command.
int parseC(float &temp, const std::string &str)
Parse the RH probe C temp command.
Namespace for all libXWC tests.