osuplusplus/test/input_stream_ops.cpp

36 lines
865 B
C++
Raw Normal View History

2024-04-30 12:19:50 +02:00
#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");
2024-04-30 12:20:34 +02:00
c = Countdown::NORMAL;
2024-04-30 12:19:50 +02:00
ss = std::stringstream("nOnE");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum mixed case #1");
2024-04-30 12:20:34 +02:00
c = Countdown::NORMAL;
2024-04-30 12:19:50 +02:00
ss = std::stringstream("NoNe");
ss >> c;
assert(c == Countdown::NONE, "failed to parse enum mixed case #2");
)
TEST_FINISH()