...

Source file src/golang.org/x/text/language/display/dict_test.go

Documentation: golang.org/x/text/language/display

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

View as plain text