mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[test] renaming test/1_stdlib to just test/stdlib
This commit is contained in:
48
test/stdlib/PrintString.swift
Normal file
48
test/stdlib/PrintString.swift
Normal file
@@ -0,0 +1,48 @@
|
||||
// RUN: rm -rf %t && mkdir %t
|
||||
// RUN: %target-build-swift -c -force-single-frontend-invocation -parse-as-library -emit-module -emit-module-path %t/PrintTestTypes.swiftmodule -o %t/PrintTestTypes.o %S/Inputs/PrintTestTypes.swift
|
||||
// RUN: %target-build-swift %s -Xlinker %t/PrintTestTypes.o -I %t -L %t -o %t/main
|
||||
// RUN: %target-run %t/main
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import PrintTestTypes
|
||||
|
||||
|
||||
let PrintTests = TestSuite("PrintString")
|
||||
PrintTests.test("Printable") {
|
||||
let s0: String = "abc"
|
||||
expectPrinted("abc", s0)
|
||||
expectDebugPrinted("\"abc\"", s0)
|
||||
|
||||
let s1: String = "\\ \' \" \0 \n \r \t \u{05}"
|
||||
expectDebugPrinted("\"\\\\ \\\' \\\" \\0 \\n \\r \\t \\u{05}\"", s1)
|
||||
|
||||
let ch: Character = "a"
|
||||
expectPrinted("a", ch)
|
||||
expectDebugPrinted("\"a\"", ch)
|
||||
|
||||
let us0: UnicodeScalar = "a"
|
||||
expectPrinted("a", us0)
|
||||
expectDebugPrinted("\"a\"", us0)
|
||||
|
||||
let us1: UnicodeScalar = "\\"
|
||||
expectPrinted("\\", us1)
|
||||
expectEqual("\"\\\\\"", us1.description)
|
||||
expectDebugPrinted("\"\\\\\"", us1)
|
||||
|
||||
let us2: UnicodeScalar = "あ"
|
||||
expectPrinted("あ", us2)
|
||||
expectEqual("\"あ\"", us2.description)
|
||||
expectDebugPrinted("\"\\u{3042}\"", us2)
|
||||
}
|
||||
|
||||
PrintTests.test("Printable") {
|
||||
expectPrinted("Optional(\"meow\")", String?("meow"))
|
||||
}
|
||||
|
||||
PrintTests.test("CustomStringInterpolation") {
|
||||
let s = ("aaa\(1)bbb" as MyString).value
|
||||
expectEqual("<segment aaa><segment 1><segment bbb>", s)
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
Reference in New Issue
Block a user