File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ module StdMap {
13
13
requires cplusplus
14
14
}
15
15
16
+ module StdOptional {
17
+ header "std-optional.h"
18
+ requires cplusplus
19
+ }
20
+
16
21
module StdSet {
17
22
header "std-set.h"
18
23
requires cplusplus
Original file line number Diff line number Diff line change
1
+ #ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
2
+ #define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
3
+
4
+ #include < optional>
5
+
6
+ using CxxOptional = std::optional<int >;
7
+
8
+ inline CxxOptional getNonNilOptional () { return {123 }; }
9
+
10
+ inline CxxOptional getNilOptional () { return {std::nullopt}; }
11
+
12
+ #endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -std=c++17)
2
+ //
3
+ // REQUIRES: executable_test
4
+ // REQUIRES: OS=macosx
5
+
6
+ import StdlibUnittest
7
+ import StdOptional
8
+ import CxxStdlib
9
+
10
+ var StdOptionalTestSuite = TestSuite ( " StdOptional " )
11
+
12
+ StdOptionalTestSuite . test ( " pointee " ) {
13
+ let nonNilOpt = getNonNilOptional ( )
14
+ let pointee = nonNilOpt. pointee
15
+ expectEqual ( 123 , pointee)
16
+ }
17
+
18
+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments