File: example_kind_test.go

package info (click to toggle)
golang-github-oschwald-maxminddb-golang-v2 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: perl: 557; makefile: 3
file content (59 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package decoder

import (
	"fmt"
)

// ExampleKind_String demonstrates human-readable Kind names.
func ExampleKind_String() {
	kinds := []Kind{KindString, KindMap, KindSlice, KindUint32, KindBool}

	for _, k := range kinds {
		fmt.Printf("%s\n", k.String())
	}

	// Output:
	// String
	// Map
	// Slice
	// Uint32
	// Bool
}

// ExampleKind_IsContainer demonstrates container type detection.
func ExampleKind_IsContainer() {
	kinds := []Kind{KindString, KindMap, KindSlice, KindUint32}

	for _, k := range kinds {
		if k.IsContainer() {
			fmt.Printf("%s is a container type\n", k.String())
		} else {
			fmt.Printf("%s is not a container type\n", k.String())
		}
	}

	// Output:
	// String is not a container type
	// Map is a container type
	// Slice is a container type
	// Uint32 is not a container type
}

// ExampleKind_IsScalar demonstrates scalar type detection.
func ExampleKind_IsScalar() {
	kinds := []Kind{KindString, KindMap, KindUint32, KindPointer}

	for _, k := range kinds {
		if k.IsScalar() {
			fmt.Printf("%s is a scalar value\n", k.String())
		} else {
			fmt.Printf("%s is not a scalar value\n", k.String())
		}
	}

	// Output:
	// String is a scalar value
	// Map is not a scalar value
	// Uint32 is a scalar value
	// Pointer is not a scalar value
}