#include #include #include #include "DBO/Result.h" template void testStream(const T& data, const std::string& ref) { std::ostringstream stream; stream << data; ASSERT_EQ(stream.str(), ref); } TEST(Result, ok) { testStream(ResultInt::ok(42), "Success: 42"); testStream(ResultInt::ok(0), "Success: 0"); testStream(ResultBool::ok(true), "Success: 1"); testStream(ResultBool::ok(false), "Success: 0"); testStream(ResultDouble::ok(0.42), "Success: 0.42"); testStream(ResultDouble::ok(-0.42), "Success: -0.42"); } TEST(Result, error) { testStream(ResultInt::error("My error label"), "Error: My error label"); testStream(ResultInt::error(""), "Error: Unknown error"); } TEST(Result, strerror) { errno = 0; testStream(ResultInt::strerror(), "Error: Success"); errno = EACCES; testStream(ResultInt::strerror(), "Error: Permission denied"); errno = 0; } int main(int argc, char* argv[]) { // std::cout << IResult::ok(42) << std::endl; // std::cout << IResult::error("Test. error") << std::endl; // errno = EACCES; // std::cout << IResult::strerror() << std::endl; // errno = 0; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }