aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/golang.org/x/net/html/entity_test.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-14 19:06:13 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-14 19:06:13 +0800
commit7fa740996cf01b56a734e579fcfcd9c2e8585ac5 (patch)
tree23a9fcf8248a12570e67155c21263f50df014f39 /Godeps/_workspace/src/golang.org/x/net/html/entity_test.go
parentc7a13c9be86417848582a2ab6704586f92dff27c (diff)
parent5f706cd7f5a97b3354b23de4273009f08586ff04 (diff)
downloadgo-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar.gz
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar.bz2
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar.lz
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar.xz
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.tar.zst
go-tangerine-7fa740996cf01b56a734e579fcfcd9c2e8585ac5.zip
Merge pull request #960 from fjl/nat-fixes
p2p/nat: fix UPnP auto discovery
Diffstat (limited to 'Godeps/_workspace/src/golang.org/x/net/html/entity_test.go')
-rw-r--r--Godeps/_workspace/src/golang.org/x/net/html/entity_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/golang.org/x/net/html/entity_test.go b/Godeps/_workspace/src/golang.org/x/net/html/entity_test.go
new file mode 100644
index 000000000..b53f866fa
--- /dev/null
+++ b/Godeps/_workspace/src/golang.org/x/net/html/entity_test.go
@@ -0,0 +1,29 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package html
+
+import (
+ "testing"
+ "unicode/utf8"
+)
+
+func TestEntityLength(t *testing.T) {
+ // We verify that the length of UTF-8 encoding of each value is <= 1 + len(key).
+ // The +1 comes from the leading "&". This property implies that the length of
+ // unescaped text is <= the length of escaped text.
+ for k, v := range entity {
+ if 1+len(k) < utf8.RuneLen(v) {
+ t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v))
+ }
+ if len(k) > longestEntityWithoutSemicolon && k[len(k)-1] != ';' {
+ t.Errorf("entity name %s is %d characters, but longestEntityWithoutSemicolon=%d", k, len(k), longestEntityWithoutSemicolon)
+ }
+ }
+ for k, v := range entity2 {
+ if 1+len(k) < utf8.RuneLen(v[0])+utf8.RuneLen(v[1]) {
+ t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v[0]) + string(v[1]))
+ }
+ }
+}