1 // $G $F.go && $L $F.$A && ./$A.out
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 func assert(a, b, c string) {
14 print("FAIL: ", c, ": ", a, "!=", b, "\n");
19 for i := 0; i < max; i++ {
29 print("\ta[", i, "] = ", ac, "; b[", i, "] =", bc, "\n");
45 "\000\123\x00\xca\xFE\u0123\ubabe\U0000babe"
54 `\000\123\x00\xca\xFE\u0123\ubabe\U0000babe`
57 assert("", ``, "empty");
58 assert(" ", " ", "blank");
59 assert("\x61", "a", "lowercase a");
60 assert("\x61", `a`, "lowercase a (backquote)");
61 assert("\u00e4", "ä", "a umlaut");
62 assert("\u00e4", `ä`, "a umlaut (backquote)");
63 assert("\u672c", "本", "nihon");
64 assert("\u672c", `本`, "nihon (backquote)");
65 assert("\x07\x08\x0c\x0a\x0d\x09\x0b\x5c\x22",
68 assert("\\a\\b\\f\\n\\r\\t\\v\\\\\\\"",
70 "backslashes (backquote)");
71 assert("\x00\x53\000\xca\376S몾몾",
72 "\000\123\x00\312\xFE\u0053\ubabe\U0000babe",
74 assert("\\000\\123\\x00\\312\\xFE\\u0123\\ubabe\\U0000babe",
75 `\000\123\x00\312\xFE\u0123\ubabe\U0000babe`,
76 "backslashes 2 (backquote)");
77 assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)");
79 // test large runes. perhaps not the most logical place for this test.
81 r = 0x10ffff; // largest rune value
83 assert(s, "\xf4\x8f\xbf\xbf", "largest rune");
86 assert(s, "\xef\xbf\xbd", "too-large rune");