Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 1 | // Copyright 2009 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Russ Cox | 3b864e4 | 2009-08-12 13:18:37 -0700 | [diff] [blame] | 5 | package strconv_test |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 6 | |
| 7 | import ( |
Robert Griesemer | d65a5cc | 2009-12-15 15:40:16 -0800 | [diff] [blame] | 8 | . "strconv" |
| 9 | "testing" |
Rob Pike | f91326b | 2012-03-07 13:50:31 +1100 | [diff] [blame] | 10 | "unicode" |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 11 | ) |
| 12 | |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 13 | // Verify that our IsPrint agrees with unicode.IsPrint. |
Rob Pike | f91326b | 2012-03-07 13:50:31 +1100 | [diff] [blame] | 14 | func TestIsPrint(t *testing.T) { |
| 15 | n := 0 |
| 16 | for r := rune(0); r <= unicode.MaxRune; r++ { |
| 17 | if IsPrint(r) != unicode.IsPrint(r) { |
| 18 | t.Errorf("IsPrint(%U)=%t incorrect", r, IsPrint(r)) |
| 19 | n++ |
| 20 | if n > 10 { |
| 21 | return |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 27 | // Verify that our IsGraphic agrees with unicode.IsGraphic. |
| 28 | func TestIsGraphic(t *testing.T) { |
| 29 | n := 0 |
| 30 | for r := rune(0); r <= unicode.MaxRune; r++ { |
| 31 | if IsGraphic(r) != unicode.IsGraphic(r) { |
| 32 | t.Errorf("IsGraphic(%U)=%t incorrect", r, IsGraphic(r)) |
| 33 | n++ |
| 34 | if n > 10 { |
| 35 | return |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
Russ Cox | 8a7cbad | 2009-01-15 17:22:17 -0800 | [diff] [blame] | 41 | type quoteTest struct { |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 42 | in string |
| 43 | out string |
| 44 | ascii string |
| 45 | graphic string |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Russ Cox | 9154943 | 2009-10-07 11:55:06 -0700 | [diff] [blame] | 48 | var quotetests = []quoteTest{ |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 49 | {"\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"`, `"\a\b\f\r\n\t\v"`, `"\a\b\f\r\n\t\v"`}, |
| 50 | {"\\", `"\\"`, `"\\"`, `"\\"`}, |
| 51 | {"abc\xffdef", `"abc\xffdef"`, `"abc\xffdef"`, `"abc\xffdef"`}, |
| 52 | {"\u263a", `"☺"`, `"\u263a"`, `"☺"`}, |
| 53 | {"\U0010ffff", `"\U0010ffff"`, `"\U0010ffff"`, `"\U0010ffff"`}, |
| 54 | {"\x04", `"\x04"`, `"\x04"`, `"\x04"`}, |
| 55 | // Some non-printable but graphic runes. Final column is double-quoted. |
| 56 | {"!\u00a0!\u2000!\u3000!", `"!\u00a0!\u2000!\u3000!"`, `"!\u00a0!\u2000!\u3000!"`, "\"!\u00a0!\u2000!\u3000!\""}, |
Russ Cox | be2edb5 | 2009-03-03 08:39:12 -0800 | [diff] [blame] | 57 | } |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 58 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 59 | func TestQuote(t *testing.T) { |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 60 | for _, tt := range quotetests { |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 61 | if out := Quote(tt.in); out != tt.out { |
Robert Griesemer | 40621d5 | 2009-11-09 12:07:39 -0800 | [diff] [blame] | 62 | t.Errorf("Quote(%s) = %s, want %s", tt.in, out, tt.out) |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 63 | } |
Russ Cox | efbeaed | 2011-12-05 15:48:21 -0500 | [diff] [blame] | 64 | if out := AppendQuote([]byte("abc"), tt.in); string(out) != "abc"+tt.out { |
| 65 | t.Errorf("AppendQuote(%q, %s) = %s, want %s", "abc", tt.in, out, "abc"+tt.out) |
| 66 | } |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | |
Rob Pike | f2f3b8f | 2011-06-07 12:23:08 +0000 | [diff] [blame] | 70 | func TestQuoteToASCII(t *testing.T) { |
| 71 | for _, tt := range quotetests { |
| 72 | if out := QuoteToASCII(tt.in); out != tt.ascii { |
| 73 | t.Errorf("QuoteToASCII(%s) = %s, want %s", tt.in, out, tt.ascii) |
| 74 | } |
Russ Cox | efbeaed | 2011-12-05 15:48:21 -0500 | [diff] [blame] | 75 | if out := AppendQuoteToASCII([]byte("abc"), tt.in); string(out) != "abc"+tt.ascii { |
| 76 | t.Errorf("AppendQuoteToASCII(%q, %s) = %s, want %s", "abc", tt.in, out, "abc"+tt.ascii) |
| 77 | } |
Rob Pike | f2f3b8f | 2011-06-07 12:23:08 +0000 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 81 | func TestQuoteToGraphic(t *testing.T) { |
| 82 | for _, tt := range quotetests { |
| 83 | if out := QuoteToGraphic(tt.in); out != tt.graphic { |
| 84 | t.Errorf("QuoteToGraphic(%s) = %s, want %s", tt.in, out, tt.graphic) |
| 85 | } |
| 86 | if out := AppendQuoteToGraphic([]byte("abc"), tt.in); string(out) != "abc"+tt.graphic { |
| 87 | t.Errorf("AppendQuoteToGraphic(%q, %s) = %s, want %s", "abc", tt.in, out, "abc"+tt.graphic) |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
Justin Nuß | 9d73a6d | 2016-01-26 21:14:35 +0100 | [diff] [blame] | 92 | func BenchmarkQuote(b *testing.B) { |
| 93 | for i := 0; i < b.N; i++ { |
| 94 | Quote("\a\b\f\r\n\t\v\a\b\f\r\n\t\v\a\b\f\r\n\t\v") |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func BenchmarkQuoteRune(b *testing.B) { |
| 99 | for i := 0; i < b.N; i++ { |
| 100 | QuoteRune('\a') |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | var benchQuoteBuf []byte |
| 105 | |
| 106 | func BenchmarkAppendQuote(b *testing.B) { |
| 107 | for i := 0; i < b.N; i++ { |
| 108 | benchQuoteBuf = AppendQuote(benchQuoteBuf[:0], "\a\b\f\r\n\t\v\a\b\f\r\n\t\v\a\b\f\r\n\t\v") |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | var benchQuoteRuneBuf []byte |
| 113 | |
| 114 | func BenchmarkAppendQuoteRune(b *testing.B) { |
| 115 | for i := 0; i < b.N; i++ { |
| 116 | benchQuoteRuneBuf = AppendQuoteRune(benchQuoteRuneBuf[:0], '\a') |
| 117 | } |
| 118 | } |
| 119 | |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 120 | type quoteRuneTest struct { |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 121 | in rune |
| 122 | out string |
| 123 | ascii string |
| 124 | graphic string |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | var quoterunetests = []quoteRuneTest{ |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 128 | {'a', `'a'`, `'a'`, `'a'`}, |
| 129 | {'\a', `'\a'`, `'\a'`, `'\a'`}, |
| 130 | {'\\', `'\\'`, `'\\'`, `'\\'`}, |
| 131 | {0xFF, `'ÿ'`, `'\u00ff'`, `'ÿ'`}, |
| 132 | {0x263a, `'☺'`, `'\u263a'`, `'☺'`}, |
| 133 | {0xfffd, `'�'`, `'\ufffd'`, `'�'`}, |
| 134 | {0x0010ffff, `'\U0010ffff'`, `'\U0010ffff'`, `'\U0010ffff'`}, |
| 135 | {0x0010ffff + 1, `'�'`, `'\ufffd'`, `'�'`}, |
| 136 | {0x04, `'\x04'`, `'\x04'`, `'\x04'`}, |
| 137 | // Some differences between graphic and printable. Note the last column is double-quoted. |
| 138 | {'\u00a0', `'\u00a0'`, `'\u00a0'`, "'\u00a0'"}, |
| 139 | {'\u2000', `'\u2000'`, `'\u2000'`, "'\u2000'"}, |
| 140 | {'\u3000', `'\u3000'`, `'\u3000'`, "'\u3000'"}, |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | func TestQuoteRune(t *testing.T) { |
| 144 | for _, tt := range quoterunetests { |
| 145 | if out := QuoteRune(tt.in); out != tt.out { |
| 146 | t.Errorf("QuoteRune(%U) = %s, want %s", tt.in, out, tt.out) |
| 147 | } |
Russ Cox | efbeaed | 2011-12-05 15:48:21 -0500 | [diff] [blame] | 148 | if out := AppendQuoteRune([]byte("abc"), tt.in); string(out) != "abc"+tt.out { |
| 149 | t.Errorf("AppendQuoteRune(%q, %U) = %s, want %s", "abc", tt.in, out, "abc"+tt.out) |
| 150 | } |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | |
Rob Pike | f2f3b8f | 2011-06-07 12:23:08 +0000 | [diff] [blame] | 154 | func TestQuoteRuneToASCII(t *testing.T) { |
| 155 | for _, tt := range quoterunetests { |
| 156 | if out := QuoteRuneToASCII(tt.in); out != tt.ascii { |
| 157 | t.Errorf("QuoteRuneToASCII(%U) = %s, want %s", tt.in, out, tt.ascii) |
| 158 | } |
Russ Cox | efbeaed | 2011-12-05 15:48:21 -0500 | [diff] [blame] | 159 | if out := AppendQuoteRuneToASCII([]byte("abc"), tt.in); string(out) != "abc"+tt.ascii { |
| 160 | t.Errorf("AppendQuoteRuneToASCII(%q, %U) = %s, want %s", "abc", tt.in, out, "abc"+tt.ascii) |
| 161 | } |
Rob Pike | f2f3b8f | 2011-06-07 12:23:08 +0000 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
Rob Pike | 74288f0 | 2015-09-02 15:08:24 -0700 | [diff] [blame] | 165 | func TestQuoteRuneToGraphic(t *testing.T) { |
| 166 | for _, tt := range quoterunetests { |
| 167 | if out := QuoteRuneToGraphic(tt.in); out != tt.graphic { |
| 168 | t.Errorf("QuoteRuneToGraphic(%U) = %s, want %s", tt.in, out, tt.graphic) |
| 169 | } |
| 170 | if out := AppendQuoteRuneToGraphic([]byte("abc"), tt.in); string(out) != "abc"+tt.graphic { |
| 171 | t.Errorf("AppendQuoteRuneToGraphic(%q, %U) = %s, want %s", "abc", tt.in, out, "abc"+tt.graphic) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
Russ Cox | 8a7cbad | 2009-01-15 17:22:17 -0800 | [diff] [blame] | 176 | type canBackquoteTest struct { |
Robert Griesemer | d65a5cc | 2009-12-15 15:40:16 -0800 | [diff] [blame] | 177 | in string |
| 178 | out bool |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Russ Cox | 9154943 | 2009-10-07 11:55:06 -0700 | [diff] [blame] | 181 | var canbackquotetests = []canBackquoteTest{ |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 182 | {"`", false}, |
| 183 | {string(0), false}, |
| 184 | {string(1), false}, |
| 185 | {string(2), false}, |
| 186 | {string(3), false}, |
| 187 | {string(4), false}, |
| 188 | {string(5), false}, |
| 189 | {string(6), false}, |
| 190 | {string(7), false}, |
| 191 | {string(8), false}, |
| 192 | {string(9), true}, // \t |
| 193 | {string(10), false}, |
| 194 | {string(11), false}, |
| 195 | {string(12), false}, |
| 196 | {string(13), false}, |
| 197 | {string(14), false}, |
| 198 | {string(15), false}, |
| 199 | {string(16), false}, |
| 200 | {string(17), false}, |
| 201 | {string(18), false}, |
| 202 | {string(19), false}, |
| 203 | {string(20), false}, |
| 204 | {string(21), false}, |
| 205 | {string(22), false}, |
| 206 | {string(23), false}, |
| 207 | {string(24), false}, |
| 208 | {string(25), false}, |
| 209 | {string(26), false}, |
| 210 | {string(27), false}, |
| 211 | {string(28), false}, |
| 212 | {string(29), false}, |
| 213 | {string(30), false}, |
| 214 | {string(31), false}, |
Rob Pike | f34251a | 2014-03-19 10:16:48 +1100 | [diff] [blame] | 215 | {string(0x7F), false}, |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 216 | {`' !"#$%&'()*+,-./:;<=>?@[\]^_{|}~`, true}, |
| 217 | {`0123456789`, true}, |
| 218 | {`ABCDEFGHIJKLMNOPQRSTUVWXYZ`, true}, |
| 219 | {`abcdefghijklmnopqrstuvwxyz`, true}, |
| 220 | {`☺`, true}, |
Volker Dobler | c0a824a | 2014-07-14 19:49:26 -0700 | [diff] [blame] | 221 | {"\x80", false}, |
| 222 | {"a\xe0\xa0z", false}, |
Volker Dobler | 3b1b840 | 2014-07-16 13:06:11 -0700 | [diff] [blame] | 223 | {"\ufeffabc", false}, |
| 224 | {"a\ufeffz", false}, |
Russ Cox | be2edb5 | 2009-03-03 08:39:12 -0800 | [diff] [blame] | 225 | } |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 226 | |
Russ Cox | 839a684 | 2009-01-20 14:40:40 -0800 | [diff] [blame] | 227 | func TestCanBackquote(t *testing.T) { |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 228 | for _, tt := range canbackquotetests { |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 229 | if out := CanBackquote(tt.in); out != tt.out { |
Robert Griesemer | 40621d5 | 2009-11-09 12:07:39 -0800 | [diff] [blame] | 230 | t.Errorf("CanBackquote(%q) = %v, want %v", tt.in, out, tt.out) |
Russ Cox | 387df5e | 2008-11-24 14:51:33 -0800 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | } |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 234 | |
Rob Pike | f2f3b8f | 2011-06-07 12:23:08 +0000 | [diff] [blame] | 235 | type unQuoteTest struct { |
| 236 | in string |
| 237 | out string |
| 238 | } |
| 239 | |
| 240 | var unquotetests = []unQuoteTest{ |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 241 | {`""`, ""}, |
| 242 | {`"a"`, "a"}, |
| 243 | {`"abc"`, "abc"}, |
| 244 | {`"☺"`, "☺"}, |
| 245 | {`"hello world"`, "hello world"}, |
| 246 | {`"\xFF"`, "\xFF"}, |
| 247 | {`"\377"`, "\377"}, |
| 248 | {`"\u1234"`, "\u1234"}, |
| 249 | {`"\U00010111"`, "\U00010111"}, |
| 250 | {`"\U0001011111"`, "\U0001011111"}, |
| 251 | {`"\a\b\f\n\r\t\v\\\""`, "\a\b\f\n\r\t\v\\\""}, |
| 252 | {`"'"`, "'"}, |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 253 | |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 254 | {`'a'`, "a"}, |
| 255 | {`'☹'`, "☹"}, |
| 256 | {`'\a'`, "\a"}, |
| 257 | {`'\x10'`, "\x10"}, |
| 258 | {`'\377'`, "\377"}, |
| 259 | {`'\u1234'`, "\u1234"}, |
| 260 | {`'\U00010111'`, "\U00010111"}, |
| 261 | {`'\t'`, "\t"}, |
| 262 | {`' '`, " "}, |
| 263 | {`'\''`, "'"}, |
| 264 | {`'"'`, "\""}, |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 265 | |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 266 | {"``", ``}, |
| 267 | {"`a`", `a`}, |
| 268 | {"`abc`", `abc`}, |
| 269 | {"`☺`", `☺`}, |
| 270 | {"`hello world`", `hello world`}, |
| 271 | {"`\\xFF`", `\xFF`}, |
| 272 | {"`\\377`", `\377`}, |
| 273 | {"`\\`", `\`}, |
Russ Cox | ba444d8 | 2011-09-26 13:59:12 -0400 | [diff] [blame] | 274 | {"`\n`", "\n"}, |
Robert Griesemer | 3478891 | 2010-10-22 10:06:33 -0700 | [diff] [blame] | 275 | {"` `", ` `}, |
| 276 | {"` `", ` `}, |
Quentin Smith | 7c46f03 | 2016-10-14 15:13:30 -0400 | [diff] [blame] | 277 | {"`a\rb`", "ab"}, |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Russ Cox | 9154943 | 2009-10-07 11:55:06 -0700 | [diff] [blame] | 280 | var misquoted = []string{ |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 281 | ``, |
| 282 | `"`, |
| 283 | `"a`, |
| 284 | `"'`, |
| 285 | `b"`, |
| 286 | `"\"`, |
Sameer Ajmani | cbf4f4b | 2012-01-09 19:55:18 -0500 | [diff] [blame] | 287 | `"\9"`, |
| 288 | `"\19"`, |
| 289 | `"\129"`, |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 290 | `'\'`, |
Sameer Ajmani | cbf4f4b | 2012-01-09 19:55:18 -0500 | [diff] [blame] | 291 | `'\9'`, |
| 292 | `'\19'`, |
| 293 | `'\129'`, |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 294 | `'ab'`, |
| 295 | `"\x1!"`, |
| 296 | `"\U12345678"`, |
| 297 | `"\z"`, |
| 298 | "`", |
| 299 | "`xxx", |
| 300 | "`\"", |
| 301 | `"\'"`, |
| 302 | `'\"'`, |
Russ Cox | ba444d8 | 2011-09-26 13:59:12 -0400 | [diff] [blame] | 303 | "\"\n\"", |
| 304 | "\"\\n\n\"", |
| 305 | "'\n'", |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | func TestUnquote(t *testing.T) { |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 309 | for _, tt := range unquotetests { |
Quentin Smith | 7c46f03 | 2016-10-14 15:13:30 -0400 | [diff] [blame] | 310 | if out, err := Unquote(tt.in); err != nil || out != tt.out { |
Robert Griesemer | 40621d5 | 2009-11-09 12:07:39 -0800 | [diff] [blame] | 311 | t.Errorf("Unquote(%#q) = %q, %v want %q, nil", tt.in, out, err, tt.out) |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | |
| 315 | // run the quote tests too, backward |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 316 | for _, tt := range quotetests { |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 317 | if in, err := Unquote(tt.out); in != tt.in { |
Robert Griesemer | 40621d5 | 2009-11-09 12:07:39 -0800 | [diff] [blame] | 318 | t.Errorf("Unquote(%#q) = %q, %v, want %q, nil", tt.out, in, err, tt.in) |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
Rob Pike | c4918db | 2011-05-25 15:04:07 +1000 | [diff] [blame] | 322 | for _, s := range misquoted { |
Russ Cox | c1178aa | 2011-10-27 19:46:31 -0700 | [diff] [blame] | 323 | if out, err := Unquote(s); out != "" || err != ErrSyntax { |
| 324 | t.Errorf("Unquote(%#q) = %q, %v want %q, %v", s, out, err, "", ErrSyntax) |
Russ Cox | 73aadff | 2009-04-13 13:27:39 -0700 | [diff] [blame] | 325 | } |
| 326 | } |
| 327 | } |
Russ Cox | ba444d8 | 2011-09-26 13:59:12 -0400 | [diff] [blame] | 328 | |
| 329 | func BenchmarkUnquoteEasy(b *testing.B) { |
| 330 | for i := 0; i < b.N; i++ { |
| 331 | Unquote(`"Give me a rock, paper and scissors and I will move the world."`) |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | func BenchmarkUnquoteHard(b *testing.B) { |
| 336 | for i := 0; i < b.N; i++ { |
| 337 | Unquote(`"\x47ive me a \x72ock, \x70aper and \x73cissors and \x49 will move the world."`) |
| 338 | } |
| 339 | } |