From 74037f12e1907e96706895191a57409ff9a2f0ca Mon Sep 17 00:00:00 2001 From: axenteoctavian Date: Mon, 22 Jan 2024 13:38:39 +0200 Subject: [PATCH] tests fixes --- common/reflectcommon/export_test.go | 43 ++--------------------------- testscommon/toml/config.toml | 2 +- testscommon/toml/overwrite.toml | 2 +- 3 files changed, 5 insertions(+), 42 deletions(-) diff --git a/common/reflectcommon/export_test.go b/common/reflectcommon/export_test.go index 10857ae97ed..84b35ba2aa0 100644 --- a/common/reflectcommon/export_test.go +++ b/common/reflectcommon/export_test.go @@ -3,50 +3,13 @@ package reflectcommon import "reflect" func FitsWithinSignedIntegerRange(value reflect.Value, targetType reflect.Type) bool { - min, err := getMinInt(targetType) - if err != nil { - return false - } - max, err := getMaxInt(targetType) - if err != nil { - return false - } - - switch value.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return value.Int() >= min && value.Int() <= max - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return value.Uint() <= uint64(max) - } - - return false + return fitsWithinSignedIntegerRange(value, targetType) } func FitsWithinUnsignedIntegerRange(value reflect.Value, targetType reflect.Type) bool { - max, err := getMaxUint(targetType) - if err != nil { - return false - } - - switch value.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return value.Int() >= 0 && uint64(value.Int()) <= max - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return value.Uint() <= max - } - - return false + return fitsWithinUnsignedIntegerRange(value, targetType) } func FitsWithinFloatRange(value reflect.Value, targetType reflect.Type) bool { - min, err := getMinFloat(targetType) - if err != nil { - return false - } - max, err := getMaxFloat(targetType) - if err != nil { - return false - } - - return value.Float() >= min && value.Float() <= max + return fitsWithinFloatRange(value, targetType) } diff --git a/testscommon/toml/config.toml b/testscommon/toml/config.toml index 465a274f147..af54141fe5f 100644 --- a/testscommon/toml/config.toml +++ b/testscommon/toml/config.toml @@ -49,4 +49,4 @@ Mesage = { Public = true, MessageDescription = [{ Text = "Text1" }, { Text = "Text2"}] } [TestMap] - Value = { "key" = 0 } \ No newline at end of file + Value = { "key" = 0 } diff --git a/testscommon/toml/overwrite.toml b/testscommon/toml/overwrite.toml index b025b16a8e7..5d1e6690caf 100644 --- a/testscommon/toml/overwrite.toml +++ b/testscommon/toml/overwrite.toml @@ -35,4 +35,4 @@ OverridableConfigTomlValues = [ { File = "config.toml", Path = "TestConfigStruct.ConfigStruct.Description", Value = { Number = "11" } }, { File = "config.toml", Path = "TestConfigNestedStruct.ConfigNestedStruct", Value = { Text = "Overwritten text", Message = { Public = false, MessageDescription = [{ Text = "Overwritten Text1" }] } } }, { File = "config.toml", Path = "TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription", Value = [{ Text = "Overwritten Text1" }, { Text = "Overwritten Text2" }] }, -] \ No newline at end of file +]