github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/unicode/graphic_test.go (about)

     1  // Copyright 2011 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 unicode_test
     6  
     7  import (
     8  	"testing"
     9  	. "unicode"
    10  )
    11  
    12  // Independently check that the special "Is" functions work
    13  // in the Latin-1 range through the property table.
    14  
    15  func TestIsControlLatin1(t *testing.T) {
    16  	for i := rune(0); i <= MaxLatin1; i++ {
    17  		got := IsControl(i)
    18  		want := false
    19  		switch {
    20  		case 0x00 <= i && i <= 0x1F:
    21  			want = true
    22  		case 0x7F <= i && i <= 0x9F:
    23  			want = true
    24  		}
    25  		if got != want {
    26  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    27  		}
    28  	}
    29  }
    30  
    31  func TestIsLetterLatin1(t *testing.T) {
    32  	for i := rune(0); i <= MaxLatin1; i++ {
    33  		got := IsLetter(i)
    34  		want := Is(Letter, i)
    35  		if got != want {
    36  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    37  		}
    38  	}
    39  }
    40  
    41  func TestIsUpperLatin1(t *testing.T) {
    42  	for i := rune(0); i <= MaxLatin1; i++ {
    43  		got := IsUpper(i)
    44  		want := Is(Upper, i)
    45  		if got != want {
    46  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    47  		}
    48  	}
    49  }
    50  
    51  func TestIsLowerLatin1(t *testing.T) {
    52  	for i := rune(0); i <= MaxLatin1; i++ {
    53  		got := IsLower(i)
    54  		want := Is(Lower, i)
    55  		if got != want {
    56  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    57  		}
    58  	}
    59  }
    60  
    61  func TestNumberLatin1(t *testing.T) {
    62  	for i := rune(0); i <= MaxLatin1; i++ {
    63  		got := IsNumber(i)
    64  		want := Is(Number, i)
    65  		if got != want {
    66  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    67  		}
    68  	}
    69  }
    70  
    71  func TestIsPrintLatin1(t *testing.T) {
    72  	for i := rune(0); i <= MaxLatin1; i++ {
    73  		got := IsPrint(i)
    74  		want := In(i, PrintRanges...)
    75  		if i == ' ' {
    76  			want = true
    77  		}
    78  		if got != want {
    79  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    80  		}
    81  	}
    82  }
    83  
    84  func TestIsGraphicLatin1(t *testing.T) {
    85  	for i := rune(0); i <= MaxLatin1; i++ {
    86  		got := IsGraphic(i)
    87  		want := In(i, GraphicRanges...)
    88  		if got != want {
    89  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
    90  		}
    91  	}
    92  }
    93  
    94  func TestIsPunctLatin1(t *testing.T) {
    95  	for i := rune(0); i <= MaxLatin1; i++ {
    96  		got := IsPunct(i)
    97  		want := Is(Punct, i)
    98  		if got != want {
    99  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
   100  		}
   101  	}
   102  }
   103  
   104  func TestIsSpaceLatin1(t *testing.T) {
   105  	for i := rune(0); i <= MaxLatin1; i++ {
   106  		got := IsSpace(i)
   107  		want := Is(White_Space, i)
   108  		if got != want {
   109  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
   110  		}
   111  	}
   112  }
   113  
   114  func TestIsSymbolLatin1(t *testing.T) {
   115  	for i := rune(0); i <= MaxLatin1; i++ {
   116  		got := IsSymbol(i)
   117  		want := Is(Symbol, i)
   118  		if got != want {
   119  			t.Errorf("%U incorrect: got %t; want %t", i, got, want)
   120  		}
   121  	}
   122  }