Skip to content

Commit c133335

Browse files
authored
Merge pull request swiftlang#41166 from zoecarver/add-stdlib-string-test
2 parents e939b90 + fefe39e commit c133335

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
module StdVector {
22
header "std-vector.h"
3-
}
3+
requires cplusplus
4+
}
5+
6+
module StdString {
7+
header "std-string.h"
8+
requires cplusplus
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H
2+
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H
3+
4+
#include <string>
5+
6+
using CxxString = std::string;
7+
8+
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_STRING_H
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
2+
//
3+
// REQUIRES: executable_test
4+
//
5+
// Enable this everywhere once we have a solution for modularizing libstdc++: rdar://87654514
6+
// REQUIRES: OS=macosx
7+
8+
import StdlibUnittest
9+
import StdString
10+
import std.string
11+
12+
var StdStringTestSuite = TestSuite("StdString")
13+
14+
StdStringTestSuite.test("init") {
15+
let s = CxxString()
16+
expectEqual(s.size(), 0)
17+
expectTrue(s.empty())
18+
}
19+
20+
// LLVM module verification fails for calls to std::string::push_back: rdar://88343327
21+
// StdStringTestSuite.test("push back") {
22+
// var s = CxxString()
23+
// s.push_back(42)
24+
// expectEqual(s.size(), 1)
25+
// expectFalse(s.empty())
26+
// expectEqual(s[0], 42)
27+
// }
28+
29+
runAllTests()

0 commit comments

Comments
 (0)