Skip to content

Commit 268eb09

Browse files
committed
[test] small string compatibility for 32-bit watchOS
1 parent 853b901 commit 268eb09

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//===--- SmallStringCompatibility.swift -----------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// RUN: %target-run-stdlib-swift
14+
15+
// REQUIRES: executable_test
16+
// REQUIRES: PTRSIZE=32
17+
/* // REQUIRES: OS=watchos */
18+
19+
import StdlibUnittest
20+
21+
var suite = TestSuite("SmallStringCompatibility")
22+
defer { runAllTests() }
23+
24+
let strings = [
25+
("Small", true),
26+
("Less small", false),
27+
("Positively large.", true),
28+
]
29+
30+
strings.forEach { (string, contiguous) in
31+
suite.test("Contiguous: \(string)")
32+
.require(.stdlib_6_2).code {
33+
34+
expectEqual(string.isContiguousUTF8, contiguous)
35+
}
36+
}
37+
38+
strings.forEach { (string, contiguous) in
39+
suite.test("Contiguous Substring: \(string)")
40+
.require(.stdlib_6_2).code {
41+
let substring = string[...]
42+
expectEqual(substring.isContiguousUTF8, contiguous)
43+
}
44+
}
45+
46+
strings.forEach { (string, contiguous) in
47+
suite.test("String.makeContiguousUTF8: \(string)")
48+
.require(.stdlib_6_2).code {
49+
var s = string
50+
s.makeContiguousUTF8()
51+
expectTrue(s.isContiguousUTF8)
52+
}
53+
}
54+
55+
strings.forEach { (string, contiguous) in
56+
suite.test("Substring.makeContiguousUTF8: \(string)")
57+
.require(.stdlib_6_2).code {
58+
var s: Substring = string.dropFirst().dropLast()
59+
s.makeContiguousUTF8()
60+
expectTrue(s.isContiguousUTF8)
61+
}
62+
}

0 commit comments

Comments
 (0)