#include "irsol/protocol/utils.hpp"
#include <catch2/catch_all.hpp>
#include <string>
Go to the source code of this file.
|
| TEST_CASE ("fromString<int>", "[Protocol][Protocol::Utils]") |
|
| TEST_CASE ("fromString<int> with invalid arg", "[Protocol][Protocol::Utils]") |
|
| TEST_CASE ("fromString<double>", "[Protocol][Protocol::Utils]") |
|
| TEST_CASE ("fromString<double>->throw", "[Protocol][Protocol::Utils]") |
|
| TEST_CASE ("fromString<string>", "[Protocol][Protocol::Utils]") |
|
| TEST_CASE ("trim", "[Protocol][Protocol::Utils]") |
|
◆ TEST_CASE() [1/6]
TEST_CASE |
( |
"fromString<double>" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 22 of file test_utils.cpp.
23{
24 auto value = GENERATE(0.0, 1.0, 1.0001, 42.43242, 31232423.123);
25
26 auto resValue = irsol::protocol::utils::fromString<double>(std::to_string(
value));
28}
◆ TEST_CASE() [2/6]
TEST_CASE |
( |
"fromString<double>->throw" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 30 of file test_utils.cpp.
31{
32 auto value = GENERATE(
"",
" ",
"-",
"42i",
"42.i",
"i42",
"42..",
"invalid");
33
34 REQUIRE_THROWS_AS(irsol::protocol::utils::fromString<double>(
value), std::invalid_argument);
35}
◆ TEST_CASE() [3/6]
TEST_CASE |
( |
"fromString<int> with invalid arg" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 14 of file test_utils.cpp.
15{
17 GENERATE("", " ", "-", "42.", "42.0", "42i", "42.i", ".42", "i42", "42..", "invalid");
18
19 REQUIRE_THROWS_AS(irsol::protocol::utils::fromString<int>(
value), std::invalid_argument);
20}
◆ TEST_CASE() [4/6]
TEST_CASE |
( |
"fromString<int>" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 6 of file test_utils.cpp.
7{
8 auto value = GENERATE(0, 1, 42, 31232423);
9
10 auto resValue = irsol::protocol::utils::fromString<int>(std::to_string(
value));
12}
◆ TEST_CASE() [5/6]
TEST_CASE |
( |
"fromString<string>" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 37 of file test_utils.cpp.
38{
39 auto value = GENERATE(
"",
"h",
"hello",
"hello world",
"4.s",
"s3");
40
41 auto resValue = irsol::protocol::utils::fromString<std::string>(
value);
43}
◆ TEST_CASE() [6/6]
TEST_CASE |
( |
"trim" |
, |
|
|
"" |
[Protocol][Protocol::Utils] |
|
) |
| |
Definition at line 45 of file test_utils.cpp.
46{
47 auto value = GENERATE(
48 "hello world",
49 " hello world",
50 "hello world ",
51 " hello world\n",
52 " hello world\t",
53 "\n\t \t\t \n\r hello world\n \r \r");
54
56 REQUIRE(trimmedValue ==
"hello world");
57}
std::string trim(const std::string &s)
Remove leading and trailing whitespace from a string.