OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 const _NOOP = 'Nothing_to_escape'; | 9 const _NOOP = 'Nothing_to_escape'; |
10 | 10 |
11 const _TEST_INPUT = """<A </test> of \xA0 "double" & 'single' values>"""; | 11 const _TEST_INPUT = """<A </test> of \xA0 "double" & 'single' values>"""; |
12 | 12 |
13 const _OUTPUT_UNKNOWN = '<A </test> of \xA0 "double" ' | 13 const _OUTPUT_UNKNOWN = '<A </test> of \xA0 "double" ' |
14 '& 'single' values>'; | 14 '& 'single' values>'; |
15 | 15 |
16 const _OUTPUT_ATTRIBUTE = | 16 const _OUTPUT_ATTRIBUTE = |
17 "<A </test> of \xA0 "double" & 'single' values>"; | 17 "<A </test> of \xA0 "double" & 'single' values>"; |
18 | 18 |
19 const _OUTPUT_SQ_ATTRIBUTE = | 19 const _OUTPUT_SQ_ATTRIBUTE = |
20 '<A </test> of \xA0 "double" & 'single' values>'; | 20 '<A </test> of \xA0 "double" & 'single' values>'; |
21 | 21 |
22 const _OUTPUT_ELEMENT = | 22 const _OUTPUT_ELEMENT = |
23 """<A </test> of \xA0 "double" & 'single' values>"""; | 23 """<A </test> of \xA0 "double" & 'single' values>"""; |
24 | 24 |
25 void _testMode(HtmlEscape escape, String input, String expected) { | 25 void _testMode(HtmlEscape escape, String input, String expected) { |
26 _testConvert(escape, input, expected); | 26 _testConvert(escape, input, expected); |
27 _testTransform(escape, input, expected); | 27 _testTransform(escape, input, expected); |
28 _testChunked(escape, input, expected); | 28 _testChunked(escape, input, expected); |
29 } | 29 } |
30 | 30 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 void main() { | 80 void main() { |
81 _testMode(HTML_ESCAPE, _TEST_INPUT, _OUTPUT_UNKNOWN); | 81 _testMode(HTML_ESCAPE, _TEST_INPUT, _OUTPUT_UNKNOWN); |
82 _testMode(const HtmlEscape(), _TEST_INPUT, _OUTPUT_UNKNOWN); | 82 _testMode(const HtmlEscape(), _TEST_INPUT, _OUTPUT_UNKNOWN); |
83 _testMode(const HtmlEscape(HtmlEscapeMode.UNKNOWN), _TEST_INPUT, _OUTPUT_UNKNO
WN); | 83 _testMode(const HtmlEscape(HtmlEscapeMode.UNKNOWN), _TEST_INPUT, _OUTPUT_UNKNO
WN); |
84 _testMode(const HtmlEscape(HtmlEscapeMode.ATTRIBUTE), _TEST_INPUT, _OUTPUT_ATT
RIBUTE); | 84 _testMode(const HtmlEscape(HtmlEscapeMode.ATTRIBUTE), _TEST_INPUT, _OUTPUT_ATT
RIBUTE); |
85 _testMode(const HtmlEscape(HtmlEscapeMode.SQ_ATTRIBUTE), _TEST_INPUT, _OUTPUT_
SQ_ATTRIBUTE); | 85 _testMode(const HtmlEscape(HtmlEscapeMode.SQ_ATTRIBUTE), _TEST_INPUT, _OUTPUT_
SQ_ATTRIBUTE); |
86 _testMode(const HtmlEscape(HtmlEscapeMode.ELEMENT), _TEST_INPUT, _OUTPUT_ELEME
NT); | 86 _testMode(const HtmlEscape(HtmlEscapeMode.ELEMENT), _TEST_INPUT, _OUTPUT_ELEME
NT); |
87 _testMode(HTML_ESCAPE, _NOOP, _NOOP); | 87 _testMode(HTML_ESCAPE, _NOOP, _NOOP); |
88 } | 88 } |
OLD | NEW |