~ubuntu-branches/ubuntu/trusty/golang/trusty

« back to all changes in this revision

Viewing changes to test/string_lit.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
                                print("\ta[", i, "] = ", ac, "; b[", i, "] =", bc, "\n")
34
34
                        }
35
35
                }
 
36
                panic("string_lit")
36
37
        }
37
38
}
38
39
 
93
94
                "backslashes 2 (backquote)")
94
95
        assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)")
95
96
 
96
 
        // test large runes. perhaps not the most logical place for this test.
 
97
        // test large and surrogate-half runes. perhaps not the most logical place for these tests.
97
98
        var r int32
98
99
        r = 0x10ffff // largest rune value
99
100
        s = string(r)
101
102
        r = 0x10ffff + 1
102
103
        s = string(r)
103
104
        assert(s, "\xef\xbf\xbd", "too-large rune")
 
105
        r = 0xD800
 
106
        s = string(r)
 
107
        assert(s, "\xef\xbf\xbd", "surrogate rune min")
 
108
        r = 0xDFFF
 
109
        s = string(r)
 
110
        assert(s, "\xef\xbf\xbd", "surrogate rune max")
 
111
        r = -1
 
112
        s = string(r)
 
113
        assert(s, "\xef\xbf\xbd", "negative rune")
 
114
 
 
115
        // the large rune tests again, this time using constants instead of a variable.
 
116
        // these conversions will be done at compile time.
 
117
        s = string(0x10ffff) // largest rune value
 
118
        assert(s, "\xf4\x8f\xbf\xbf", "largest rune constant")
 
119
        s = string(0x10ffff + 1)
 
120
        assert(s, "\xef\xbf\xbd", "too-large rune constant")
 
121
        s = string(0xD800)
 
122
        assert(s, "\xef\xbf\xbd", "surrogate rune min constant")
 
123
        s = string(0xDFFF)
 
124
        assert(s, "\xef\xbf\xbd", "surrogate rune max constant")
 
125
        s = string(-1)
 
126
        assert(s, "\xef\xbf\xbd", "negative rune")
104
127
 
105
128
        assert(string(gr1), gx1, "global ->[]rune")
106
129
        assert(string(gr2), gx2fix, "global invalid ->[]rune")