]> Cypherpunks repositories - gostls13.git/commitdiff
unicode: add examples for the Is functions
authorPedro Lopez Mareque <pedro.lopez.mareque@gmail.com>
Sat, 2 Oct 2021 14:14:58 +0000 (16:14 +0200)
committerIan Lance Taylor <iant@golang.org>
Wed, 6 Oct 2021 23:19:13 +0000 (23:19 +0000)
Change-Id: If4afe33985dc0a758db32564244095190b82e5c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/353691
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Rob Pike <r@golang.org>
src/unicode/example_test.go

index 50c5b18a48e63d8269996a21e810fbface9e6acf..416ad1fe083481ab19892a75c5d3a5d9c10636df 100644 (file)
@@ -194,3 +194,63 @@ func ExampleSpecialCase() {
        // U+0130 'İ'
        // U+0130 'İ'
 }
+
+func ExampleIsDigit() {
+       fmt.Printf("%t\n", unicode.IsDigit('৩'))
+       fmt.Printf("%t\n", unicode.IsDigit('A'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsNumber() {
+       fmt.Printf("%t\n", unicode.IsNumber('Ⅷ'))
+       fmt.Printf("%t\n", unicode.IsNumber('A'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsLetter() {
+       fmt.Printf("%t\n", unicode.IsLetter('A'))
+       fmt.Printf("%t\n", unicode.IsLetter('7'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsLower() {
+       fmt.Printf("%t\n", unicode.IsLower('a'))
+       fmt.Printf("%t\n", unicode.IsLower('A'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsUpper() {
+       fmt.Printf("%t\n", unicode.IsUpper('A'))
+       fmt.Printf("%t\n", unicode.IsUpper('a'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsTitle() {
+       fmt.Printf("%t\n", unicode.IsTitle('Dž'))
+       fmt.Printf("%t\n", unicode.IsTitle('a'))
+       // Output:
+       // true
+       // false
+}
+
+func ExampleIsSpace() {
+       fmt.Printf("%t\n", unicode.IsSpace(' '))
+       fmt.Printf("%t\n", unicode.IsSpace('\n'))
+       fmt.Printf("%t\n", unicode.IsSpace('\t'))
+       fmt.Printf("%t\n", unicode.IsUpper('a'))
+       // Output:
+       // true
+       // true
+       // true
+       // false
+}