adds testing for floats and bool

This commit is contained in:
Hyatt 2024-02-12 11:34:15 -06:00
parent 7e2422a0a9
commit 3a44c4ff7a
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"math"
"strconv" "strconv"
"testing" "testing"
) )
@ -184,19 +185,23 @@ func TestTypeConversion(t *testing.T) {
t.Fatalf("Expected: %d, got: %d", 100, output_uint64) t.Fatalf("Expected: %d, got: %d", 100, output_uint64)
} }
/*
// float32 // float32
output_float32, _ := typeConversion("float32", "100.001") output_float32, _ := typeConversion("float32", "100.001")
if float32(output_float32.(float64)) != float32(100.1) { if float32(math.Round(output_float32.(float64)*1000)/1000) != float32(math.Round(100.001*1000)/1000) {
t.Fatalf("Expected: %f, got: %f", 100.1, output_float32) t.Fatalf("Expected: %f, got: %f", float32(math.Round(100.001*1000)/1000), float32(math.Round(output_float32.(float64)*1000)/1000))
} }
// float64 // float64
output_float64, _ := typeConversion("float64", "100.001") output_float64, _ := typeConversion("float64", "100.001")
if output_float64.(float64) != 100.001 { if math.Round(output_float64.(float64)*1000)/1000 != math.Round(100.001*1000)/1000 {
t.Fatalf("Expected: %f, got: %f", 100.001, output_float64) t.Fatalf("Expected: %f, got: %f", math.Round(100.001*1000)/1000, math.Round(output_float64.(float64)*1000)/1000)
}
// bool
output_bool, _ := typeConversion("bool", "true")
if output_bool.(bool) != true {
t.Fatalf("Expected: %t, got: %t", true, output_bool.(bool))
} }
*/
} }
func TestParseFlags(t *testing.T) { func TestParseFlags(t *testing.T) {