add initial input stream op tests
This commit is contained in:
parent
39e3b16568
commit
396d9418fe
2 changed files with 32 additions and 1 deletions
|
@ -3,7 +3,7 @@ CXXFLAGS += $(addprefix -I, $(INCLUDE))
|
||||||
|
|
||||||
TEST = test
|
TEST = test
|
||||||
|
|
||||||
_TESTS = example.cpp
|
_TESTS = example.cpp input_stream_ops.cpp
|
||||||
TESTS = $(addprefix $(TEST)/, $(_TESTS))
|
TESTS = $(addprefix $(TEST)/, $(_TESTS))
|
||||||
|
|
||||||
OBJ = $(addprefix $(BIN)/, $(_TESTS:.cpp=))
|
OBJ = $(addprefix $(BIN)/, $(_TESTS:.cpp=))
|
||||||
|
|
31
test/input_stream_ops.cpp
Normal file
31
test/input_stream_ops.cpp
Normal 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()
|
||||||
|
|
Loading…
Reference in a new issue