aboutsummaryrefslogtreecommitdiff
path: root/src/unicode
diff options
context:
space:
mode:
authorPedro Lopez Mareque <pedro.lopez.mareque@gmail.com>2021-10-02 16:14:58 +0200
committerIan Lance Taylor <iant@golang.org>2021-10-06 23:19:13 +0000
commit4707a6c284a9d8a0927cbc1badc6d09535a79bff (patch)
tree2ec0c98caa46e371d0bf3c364df20b4249551600 /src/unicode
parent4ffa2f1c23d5d43be18c4ebf74ca553119683670 (diff)
downloadgo-4707a6c284a9d8a0927cbc1badc6d09535a79bff.tar.xz
unicode: add examples for the Is functions
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>
Diffstat (limited to 'src/unicode')
-rw-r--r--src/unicode/example_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/unicode/example_test.go b/src/unicode/example_test.go
index 50c5b18a48..416ad1fe08 100644
--- a/src/unicode/example_test.go
+++ b/src/unicode/example_test.go
@@ -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
+}