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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
package backrest
import "testing"
func TestConvertBoolToFloat64(t *testing.T) {
type args struct {
value bool
}
tests := []struct {
name string
args args
want float64
}{
{"ConvertBoolToFloat64True",
args{true},
1,
},
{"ConvertBoolToFloat64False",
args{false},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertBoolToFloat64(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
func TestConvertBoolPointerToFloat64(t *testing.T) {
type args struct {
value *bool
}
tests := []struct {
name string
args args
want float64
}{
{"ConvertBoolPointerToFloat64True",
args{valToPtr(bool(true))},
1,
},
{"ConvertBoolPointerToFloat64False",
args{valToPtr(bool(false))},
0,
},
{"ConvertBoolPointerToFloat64Nil",
args{nil},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertBoolPointerToFloat64(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
func TestConvertInt64PointerToFloat64(t *testing.T) {
type args struct {
value *int64
}
tests := []struct {
name string
args args
want float64
}{
{"ConvertInt64PointerToFloat64One",
args{valToPtr(int64(1))},
1,
},
{"ConvertInt64PointerToFloat64Nil",
args{nil},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertInt64PointerToFloat64(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
func TestConvertAnnotationPointerToFloat64(t *testing.T) {
type args struct {
value *annotation
}
tests := []struct {
name string
args args
want float64
}{
{"ConvertAnnotationPointerToFloat64NotNil",
args{valToPtr(annotation{"testkey": "testvalue"})},
1,
},
{"ConvertAnnotationPointerToFloat64Nil",
args{nil},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertAnnotationPointerToFloat64(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
func TestConvertDatabaseRefPointerToFloat(t *testing.T) {
type args struct {
value *[]databaseRef
}
tests := []struct {
name string
args args
want float64
}{
{"ConvertDatabaseRefPointerToFloatNotNil",
args{valToPtr([]databaseRef{{"postgres", 13425}})},
1,
},
{"ConvertDatabaseRefPointerToFloatNil",
args{nil},
0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertDatabaseRefPointerToFloat(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
func TestConvertEmptyLSNValueLabel(t *testing.T) {
type args struct {
value string
}
tests := []struct {
name string
args args
want string
}{
{"ConvertEmptyLSNValueLabelNil",
args{""},
"-",
},
{"ConvertEmptyLSNValueLabelNotNil",
args{"0/2000028"},
"0/2000028",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convertEmptyLSNValueLabel(tt.args.value); got != tt.want {
t.Errorf("\nVariables do not match:\n%v\nwant:\n%v", got, tt.want)
}
})
}
}
|