File tree 5 files changed +562
-0
lines changed
5 files changed +562
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ target_link_libraries(${PROJECT_NAME} Catch2::Catch2)
13
13
target_sources (${PROJECT_NAME}
14
14
PRIVATE
15
15
base_tests.cpp
16
+ monadic_tests.cpp
16
17
test_expected_main.cpp
17
18
)
18
19
@@ -29,6 +30,7 @@ target_link_libraries(${PROJECT_NAME}_cpp20 Catch2::Catch2)
29
30
target_sources (${PROJECT_NAME} _cpp20
30
31
PRIVATE
31
32
base_tests.cpp
33
+ monadic_tests.cpp
32
34
test_expected_main.cpp
33
35
)
34
36
@@ -45,5 +47,6 @@ target_link_libraries(${PROJECT_NAME}_cpp23 Catch2::Catch2)
45
47
target_sources (${PROJECT_NAME} _cpp23
46
48
PRIVATE
47
49
base_tests.cpp
50
+ monadic_tests.cpp
48
51
test_expected_main.cpp
49
52
)
Original file line number Diff line number Diff line change
1
+ #include < string>
2
+
3
+ #include < catch2/catch_all.hpp>
4
+
5
+ #include < zeus/expected.hpp>
6
+
7
+ using namespace zeus ;
8
+
9
+ TEST_CASE (" and_then()" , " [monadic]" )
10
+ {
11
+ using T = std::string;
12
+ using Expected = expected<int , T>;
13
+
14
+ { // non-void
15
+ using Expected2 = expected<double , T>;
16
+
17
+ Expected e = 42 ;
18
+
19
+ auto const newVal = e.and_then ([](int x) { return Expected2 {x * 2 }; });
20
+
21
+ static_assert (std::is_same_v<std::remove_cv_t <decltype (newVal)>, Expected2>);
22
+ }
23
+ { // void
24
+ using Expected2 = expected<void , T>;
25
+
26
+ Expected e = 42 ;
27
+
28
+ auto const newVal = e.and_then ([](int ) -> Expected2 { return Expected2 {}; });
29
+
30
+ static_assert (std::is_same_v<std::remove_cv_t <decltype (newVal)>, Expected2>);
31
+ }
32
+ }
Original file line number Diff line number Diff line change 1
1
add_subdirectory (msvc_stl_p0323r12_test)
2
+ add_subdirectory (msvc_stl_p2505r5_test)
Original file line number Diff line number Diff line change
1
+ project (msvc_stl_p2505r5_test)
2
+ add_executable (${PROJECT_NAME} )
3
+ set_target_properties (${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
4
+
5
+ target_link_libraries (${PROJECT_NAME} zeus::expected)
6
+
7
+ target_sources (${PROJECT_NAME}
8
+ PRIVATE
9
+ msvc_stl_p2505r5_test.cpp
10
+ )
You can’t perform that action at this time.
0 commit comments