Skip to content

Commit c404cf2

Browse files
committed
Failing string ordering on linux test
This testcase illustrates a problem on linux where - at the time of writing - the strings "a" and "a\0" satisfied "a" <= "a\0" "a" >= "a\0" "a" != "a\0"
1 parent 033934d commit c404cf2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %target-run-simple-swift
2+
// REQUIRES: executable_test
3+
4+
import StdlibUnittest
5+
6+
// Also import modules which are used by StdlibUnittest internally. This
7+
// workaround is needed to link all required libraries in case we compile
8+
// StdlibUnittest with -sil-serialize-all.
9+
import SwiftPrivate
10+
#if _runtime(_ObjC)
11+
import ObjectiveC
12+
#endif
13+
14+
var StringOrderRelationTestSuite = TestSuite("StringOrderRelation")
15+
16+
StringOrderRelationTestSuite.test("StringOrderRelation/ASCII/NullByte") {
17+
let baseString = "a"
18+
let nullbyteString = "a\0"
19+
expectTrue(baseString < nullbyteString)
20+
expectTrue(baseString <= nullbyteString)
21+
expectFalse(baseString > nullbyteString)
22+
expectFalse(baseString >= nullbyteString)
23+
expectFalse(baseString == nullbyteString)
24+
expectTrue(baseString != nullbyteString)
25+
}
26+
27+
runAllTests()
28+

0 commit comments

Comments
 (0)