File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " common/result.hpp"
22
3+ #include < string>
4+
35// there'll be a lot of unused variables, since we just want to see if it compiles
46#pragma GCC diagnostic ignored "-Wunused-variable"
57
6- class MyError {};
8+ class MyError {
9+ public:
10+ constexpr MyError (std::string) {}
11+
12+ constexpr MyError () {}
13+ };
714
815class MyError2 {};
916
@@ -22,7 +29,17 @@ zest::Result<int, MyError> test_function_2() {
2229}
2330
2431constexpr void compile_time_tests () {
25- // test sentinel values
32+ {
33+ // check constructors
34+ zest::Result<int , MyError> a (MyError{});
35+ zest::Result<int , MyError> b (" test_MyError_conversion" );
36+ zest::Result<int , MyError> c (2 );
37+ zest::Result<int , MyError> d (2.0 );
38+ zest::Result<int , MyError> e;
39+ zest::Result<void , MyError> f (MyError{});
40+ zest::Result<void , MyError> g (" test_MyError_conversion" );
41+ }
42+
2643 {
2744 // test comparison operator
2845 static_assert (zest::Result<int , MyError>(2 ) == zest::Result<int , MyError>(2 ));
@@ -42,10 +59,6 @@ constexpr void compile_time_tests() {
4259 const int && e = zest::Result<int , MyError>(2 );
4360 int f = a;
4461 }
45-
46- {
47- // test error getting
48- }
4962}
5063
5164void runtime_tests () {}
You can’t perform that action at this time.
0 commit comments