diff --git a/include/libimp/result.h b/include/libimp/result.h index 691fe32..c8f90d7 100644 --- a/include/libimp/result.h +++ b/include/libimp/result.h @@ -42,7 +42,7 @@ struct generic_traits { /// \brief Custom initialization. constexpr static void init_code(storage_t &code) noexcept { - code = {0, std::make_error_code(std::errc::invalid_argument)}; + code = {0, std::error_code(-1, std::generic_category())}; } constexpr static void init_code(storage_t &code, T value, std::error_code const &ec) noexcept { code = {value, ec}; @@ -73,7 +73,7 @@ struct default_traits { /// \brief Custom initialization. constexpr static void init_code(storage_t &code) noexcept { - code = std::make_error_code(std::errc::invalid_argument); + code = std::error_code(-1, std::generic_category()); } constexpr static void init_code(storage_t &code, std::error_code const &ec) noexcept { code = ec; @@ -96,7 +96,7 @@ struct default_traits::value>> : generic /// \brief Custom initialization. constexpr static void init_code(typename generic_traits::storage_t &code, T value, bool ok) noexcept { - code = {value, ok ? std::error_code() : std::make_error_code(std::errc::invalid_argument)}; + code = {value, ok ? std::error_code() : std::error_code(-1, std::generic_category())}; } using generic_traits::init_code; @@ -113,7 +113,7 @@ struct default_traits::value>> : generic_ } constexpr static void init_code(typename generic_traits::storage_t &code, std::nullptr_t) noexcept { - code = {nullptr, std::make_error_code(std::errc::invalid_argument)}; + code = {nullptr, std::error_code(-1, std::generic_category())}; } using generic_traits::init_code; diff --git a/test/imp/test_imp_error.cpp b/test/imp/test_imp_error.cpp index 8693890..8dfb4ef 100644 --- a/test/imp/test_imp_error.cpp +++ b/test/imp/test_imp_error.cpp @@ -10,5 +10,5 @@ TEST(error, error_code) { std::error_code ecode; EXPECT_FALSE(ecode); std::cout << ecode.message() << "\n"; - EXPECT_EQ(ecode.message(), "[generic: 0, \"success\"]"); + EXPECT_EQ(ecode.message(), "Success"); } diff --git a/test/imp/test_imp_result.cpp b/test/imp/test_imp_result.cpp index dd6248a..efe23b6 100644 --- a/test/imp/test_imp_result.cpp +++ b/test/imp/test_imp_result.cpp @@ -102,11 +102,11 @@ TEST(result, fmt) { imp::result r3 {&aaa}; EXPECT_EQ(imp::fmt(r3), imp::fmt("succ, value = ", (void *)&aaa)); imp::result r4 {nullptr}; - EXPECT_EQ(imp::fmt(r4), imp::fmt("fail, value = ", nullptr, ", error = [generic: 0, \"failure\"]")); + EXPECT_EQ(imp::fmt(r4), imp::fmt("fail, value = ", nullptr, ", error = [-1: Unknown error -1]")); r4 = {nullptr, std::error_code{1234, std::generic_category()}}; - EXPECT_EQ(imp::fmt(r4), imp::fmt("fail, value = ", nullptr, ", error = [generic: 1234, \"failure\"]")); + EXPECT_EQ(imp::fmt(r4), imp::fmt("fail, value = ", nullptr, ", error = [1234: Unknown error 1234]")); imp::result r5; - EXPECT_EQ(imp::fmt(r5), "fail, value = null, error = [generic: 0, \"failure\"]"); + EXPECT_EQ(imp::fmt(r5), "fail, value = null, error = [-1: Unknown error -1]"); } { imp::result r1 {-123}; @@ -114,9 +114,9 @@ TEST(result, fmt) { } { imp::result r1; - EXPECT_EQ(imp::fmt(r1), "fail, error = [generic: 0, \"failure\"]"); + EXPECT_EQ(imp::fmt(r1), "fail, error = [-1: Unknown error -1]"); r1 = std::error_code{}; EXPECT_TRUE(r1); - EXPECT_EQ(imp::fmt(r1), "succ, error = [generic: 0, \"success\"]"); + EXPECT_EQ(imp::fmt(r1), "succ, error = [0: Success]"); } } diff --git a/test/imp/test_imp_system.cpp b/test/imp/test_imp_system.cpp index 51500b8..6ac2629 100644 --- a/test/imp/test_imp_system.cpp +++ b/test/imp/test_imp_system.cpp @@ -9,11 +9,6 @@ #include "libimp/codecvt.h" #include "libimp/fmt.h" -#if defined(LIBIMP_OS_WIN) -#include -#else -#endif - TEST(system, conf) { auto ret = imp::sys::conf(imp::sys::info::page_size); EXPECT_TRUE(ret);