github.com/primecitizens/pcz/std@v0.2.1/text/unicode/digit_test.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2009 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package unicode_test 9 10 import ( 11 "testing" 12 . "unicode" 13 ) 14 15 var testDigit = []rune{ 16 0x0030, 17 0x0039, 18 0x0661, 19 0x06F1, 20 0x07C9, 21 0x0966, 22 0x09EF, 23 0x0A66, 24 0x0AEF, 25 0x0B66, 26 0x0B6F, 27 0x0BE6, 28 0x0BEF, 29 0x0C66, 30 0x0CEF, 31 0x0D66, 32 0x0D6F, 33 0x0E50, 34 0x0E59, 35 0x0ED0, 36 0x0ED9, 37 0x0F20, 38 0x0F29, 39 0x1040, 40 0x1049, 41 0x1090, 42 0x1091, 43 0x1099, 44 0x17E0, 45 0x17E9, 46 0x1810, 47 0x1819, 48 0x1946, 49 0x194F, 50 0x19D0, 51 0x19D9, 52 0x1B50, 53 0x1B59, 54 0x1BB0, 55 0x1BB9, 56 0x1C40, 57 0x1C49, 58 0x1C50, 59 0x1C59, 60 0xA620, 61 0xA629, 62 0xA8D0, 63 0xA8D9, 64 0xA900, 65 0xA909, 66 0xAA50, 67 0xAA59, 68 0xFF10, 69 0xFF19, 70 0x104A1, 71 0x1D7CE, 72 } 73 74 var testLetter = []rune{ 75 0x0041, 76 0x0061, 77 0x00AA, 78 0x00BA, 79 0x00C8, 80 0x00DB, 81 0x00F9, 82 0x02EC, 83 0x0535, 84 0x06E6, 85 0x093D, 86 0x0A15, 87 0x0B99, 88 0x0DC0, 89 0x0EDD, 90 0x1000, 91 0x1200, 92 0x1312, 93 0x1401, 94 0x1885, 95 0x2C00, 96 0xA800, 97 0xF900, 98 0xFA30, 99 0xFFDA, 100 0xFFDC, 101 0x10000, 102 0x10300, 103 0x10400, 104 0x20000, 105 0x2F800, 106 0x2FA1D, 107 } 108 109 func TestDigit(t *testing.T) { 110 for _, r := range testDigit { 111 if !IsDigit(r) { 112 t.Errorf("IsDigit(U+%04X) = false, want true", r) 113 } 114 } 115 for _, r := range testLetter { 116 if IsDigit(r) { 117 t.Errorf("IsDigit(U+%04X) = true, want false", r) 118 } 119 } 120 } 121 122 // Test that the special case in IsDigit agrees with the table 123 func TestDigitOptimization(t *testing.T) { 124 for i := rune(0); i <= MaxLatin1; i++ { 125 if Is(Digit, i) != IsDigit(i) { 126 t.Errorf("IsDigit(U+%04X) disagrees with Is(Digit)", i) 127 } 128 } 129 }