MCPcopy Index your code
hub / github.com/Masterminds/sprig / TestToInt

Function TestToInt

numeric_test.go:157–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestToInt(t *testing.T) {
158 target := int(102)
159 if target != toInt(int8(102)) {
160 t.Errorf("Expected 102")
161 }
162 if target != toInt(int(102)) {
163 t.Errorf("Expected 102")
164 }
165 if target != toInt(int32(102)) {
166 t.Errorf("Expected 102")
167 }
168 if target != toInt(int16(102)) {
169 t.Errorf("Expected 102")
170 }
171 if target != toInt(int64(102)) {
172 t.Errorf("Expected 102")
173 }
174 if target != toInt("102") {
175 t.Errorf("Expected 102")
176 }
177 if 0 != toInt("frankie") {
178 t.Errorf("Expected 0")
179 }
180 if target != toInt(uint16(102)) {
181 t.Errorf("Expected 102")
182 }
183 if target != toInt(uint64(102)) {
184 t.Errorf("Expected 102")
185 }
186 if target != toInt(float64(102.1234)) {
187 t.Errorf("Expected 102")
188 }
189 if 1 != toInt(true) {
190 t.Errorf("Expected 102")
191 }
192}
193
194func TestToDecimal(t *testing.T) {
195 tests := map[interface{}]int64{

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…