dict_test.go 928 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2015 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. package display
  5. import (
  6. "fmt"
  7. "testing"
  8. "golang.org/x/text/internal/testtext"
  9. )
  10. func TestLinking(t *testing.T) {
  11. base := getSize(t, `display.Tags(language.English).Name(language.English)`)
  12. compact := getSize(t, `display.English.Languages().Name(language.English)`)
  13. if d := base - compact; d < 1.5*1024*1024 {
  14. t.Errorf("size(base) - size(compact) = %d - %d = was %d; want > 1.5MB", base, compact, d)
  15. }
  16. }
  17. func getSize(t *testing.T, main string) int {
  18. size, err := testtext.CodeSize(fmt.Sprintf(body, main))
  19. if err != nil {
  20. t.Skipf("skipping link size test; binary size could not be determined: %v", err)
  21. }
  22. return size
  23. }
  24. const body = `package main
  25. import (
  26. "golang.org/x/text/language"
  27. "golang.org/x/text/language/display"
  28. )
  29. func main() {
  30. %s
  31. }
  32. `