...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package valutil_test
16
17 import (
18 "testing"
19
20 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/valutil"
21 )
22
23 func TestIsDefaultValue(t *testing.T) {
24 testCases := []struct {
25 Name string
26 Value interface{}
27 ExpectedResult bool
28 }{
29 {
30 Name: "Default string",
31 Value: "",
32 ExpectedResult: true,
33 },
34 {
35 Name: "String value",
36 Value: "a",
37 ExpectedResult: false,
38 },
39 {
40 Name: "Default bool",
41 Value: false,
42 ExpectedResult: true,
43 },
44 {
45 Name: "Bool value",
46 Value: true,
47 ExpectedResult: false,
48 },
49 {
50 Name: "Pointer to string",
51 Value: new(string),
52 ExpectedResult: true,
53 },
54 {
55 Name: "Pointer to bool",
56 Value: new(bool),
57 ExpectedResult: true,
58 },
59 }
60 for _, tc := range testCases {
61 t.Run(tc.Name, func(t *testing.T) {
62 result := valutil.IsDefaultValue(tc.Value)
63 if result != tc.ExpectedResult {
64 t.Fatalf("unexpected result: got '%v', want '%v'", result, tc.ExpectedResult)
65 }
66 })
67 }
68 }
69
View as plain text