diff --git a/test/Interop/Cxx/stdlib/Inputs/module.modulemap b/test/Interop/Cxx/stdlib/Inputs/module.modulemap index a4d09ff5caeb9..c11b0a85a2a0c 100644 --- a/test/Interop/Cxx/stdlib/Inputs/module.modulemap +++ b/test/Interop/Cxx/stdlib/Inputs/module.modulemap @@ -1,3 +1,9 @@ module StdVector { header "std-vector.h" -} \ No newline at end of file + requires cplusplus +} + +module StdString { + header "std-string.h" + requires cplusplus +} diff --git a/test/Interop/Cxx/stdlib/Inputs/std-string.h b/test/Interop/Cxx/stdlib/Inputs/std-string.h new file mode 100644 index 0000000000000..730aaa5cc3e4d --- /dev/null +++ b/test/Interop/Cxx/stdlib/Inputs/std-string.h @@ -0,0 +1,8 @@ +#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H +#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H + +#include + +using CxxString = std::string; + +#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H \ No newline at end of file diff --git a/test/Interop/Cxx/stdlib/use-std-string.swift b/test/Interop/Cxx/stdlib/use-std-string.swift new file mode 100644 index 0000000000000..74dd8227e3d26 --- /dev/null +++ b/test/Interop/Cxx/stdlib/use-std-string.swift @@ -0,0 +1,29 @@ +// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop) +// +// REQUIRES: executable_test +// +// Enable this everywhere once we have a solution for modularizing libstdc++: rdar://87654514 +// REQUIRES: OS=macosx + +import StdlibUnittest +import StdString +import std.string + +var StdStringTestSuite = TestSuite("StdString") + +StdStringTestSuite.test("init") { + let s = CxxString() + expectEqual(s.size(), 0) + expectTrue(s.empty()) +} + +// LLVM module verification fails for calls to std::string::push_back: rdar://88343327 +// StdStringTestSuite.test("push back") { +// var s = CxxString() +// s.push_back(42) +// expectEqual(s.size(), 1) +// expectFalse(s.empty()) +// expectEqual(s[0], 42) +// } + +runAllTests()