Files
swift-mirror/test/Interop/Cxx/stdlib/use-std-string.swift
Egor Zhdan e3c58386b7 [cxx-interop] Recognize CxxStdlib as an alias for std
C++ standard library module is called `std`. To make it more clear to a Swift developer that this module is a C++ stdlib, and not a Swift stdlib, let's rename it to `CxxStdlib`.

This is the first step in the module rename. We don't ban `std` in this patch to be able to build SwiftCompilerSources with hosttools until a new Swift compiler is shipped.
2022-09-15 14:37:38 +01:00

43 lines
1.0 KiB
Swift

// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
// RUN: %target-run-simple-swift(-D USE_CXXSTDLIB_SPELLING -I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
//
// REQUIRES: executable_test
//
// Enable this everywhere once we have a solution for modularizing other C++ stdlibs: rdar://87654514
// REQUIRES: OS=macosx || OS=linux-gnu
import StdlibUnittest
import StdString
#if os(Linux)
#if USE_CXXSTDLIB_SPELLING
import CxxStdlib
#else
import std
#endif
// FIXME: import CxxStdlib.string once libstdc++ is split into submodules.
#else
#if USE_CXXSTDLIB_SPELLING
import CxxStdlib.string
#else
import std.string
#endif
#endif
var StdStringTestSuite = TestSuite("StdString")
StdStringTestSuite.test("init") {
let s = CxxString()
expectEqual(s.size(), 0)
expectTrue(s.empty())
}
StdStringTestSuite.test("push back") {
var s = CxxString()
s.push_back(42)
expectEqual(s.size(), 1)
expectFalse(s.empty())
expectEqual(s[0], 42)
}
runAllTests()