unicode/norm: test unused tables are dropped
Change-Id: Ie068d74c4c66a7bc38945e3c3b092349fad9d26e
Reviewed-on: https://go-review.googlesource.com/36870
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
diff --git a/unicode/norm/normalize_test.go b/unicode/norm/normalize_test.go
index 04810e7..ffa1034 100644
--- a/unicode/norm/normalize_test.go
+++ b/unicode/norm/normalize_test.go
@@ -878,6 +878,25 @@
})
}
+func TestLinking(t *testing.T) {
+ const prog = `
+ package main
+ import "fmt"
+ import "golang.org/x/text/unicode/norm"
+ func main() { fmt.Println(norm.%s) }
+ `
+ baseline, errB := testtext.CodeSize(fmt.Sprintf(prog, "MaxSegmentSize"))
+ withTables, errT := testtext.CodeSize(fmt.Sprintf(prog, `NFC.String("")`))
+ if errB != nil || errT != nil {
+ t.Skipf("code size failed: %v and %v", errB, errT)
+ }
+ // Tables are at least 50K
+ if d := withTables - baseline; d < 50*1024 {
+ t.Errorf("tables appear not to be dropped: %d - %d = %d",
+ withTables, baseline, d)
+ }
+}
+
func appendBench(f Form, in []byte) func() {
buf := make([]byte, 0, 4*len(in))
return func() {