add initial input stream op tests

This commit is contained in:
jacekpoz 2024-04-30 12:19:50 +02:00
parent 39e3b16568
commit 396d9418fe
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 32 additions and 1 deletions

View file

@ -3,7 +3,7 @@ CXXFLAGS += $(addprefix -I, $(INCLUDE))
TEST = test
_TESTS = example.cpp
_TESTS = example.cpp input_stream_ops.cpp
TESTS = $(addprefix $(TEST)/, $(_TESTS))
OBJ = $(addprefix $(BIN)/, $(_TESTS:.cpp=))

31
test/input_stream_ops.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <test.hpp>
#include <config.hpp>
#include <sstream>
TEST_START()
TEST("enum input stream operators work",
Countdown c = Countdown::NORMAL;
std::stringstream ss("NONE");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum");
)
TEST("enum input stream operators ignore case",
Countdown c = Countdown::NORMAL;
std::stringstream ss("none");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum all lowercase");
ss = std::stringstream("nOnE");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum mixed case #1");
ss = std::stringstream("NoNe");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum mixed case #2");
)
TEST_FINISH()