blob: 368fd216e9a96d2bbc3d66f68e5979a1f2e38af0 [file] [log] [blame]
/*
* Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/
/**
* @assertion const HtmlEscapeMode({
* String name: "custom",
* bool escapeLtGt: false,
* bool escapeQuot: false,
* bool escapeApos: false,
* bool escapeSlash: false
* })
* Create a custom escaping mode.
*
* All modes escape &. The mode can further be set to escape < and >
* (escapeLtGt), " (escapeQuot), ' (escapeApos), and/or / (escapeSlash).
* @description Checks that this constructor creates a custom escaping mode.
* Test escapeQuot true
* @author sgrekhov@unipro.ru
*/
import "dart:convert";
import "../../../Utils/expect.dart";
var symbols = ["&", "\""];
var escape = ["&amp;", "&quot;"];
var notEscaped = ["'", "<", ">", "/"];
main() {
HtmlEscapeMode htmlEscapeMode = new HtmlEscapeMode(escapeQuot: true);
HtmlEscape converter = new HtmlEscape(htmlEscapeMode);
for (int i = 0; i < symbols.length; i++) {
Expect.equals(escape[i], converter.convert(symbols[i]));
}
for (int i = 0; i < notEscaped.length; i++) {
Expect.equals(notEscaped[i], converter.convert(notEscaped[i]));
}
Expect.equals(htmlEscapeMode, converter.mode);
Expect.isFalse(htmlEscapeMode.escapeApos);
Expect.isFalse(htmlEscapeMode.escapeLtGt);
Expect.isTrue(htmlEscapeMode.escapeQuot);
Expect.isFalse(htmlEscapeMode.escapeSlash);
}