int-itrator: new iterator over integer ranges
This commit is contained in:
@@ -122,6 +122,32 @@ func TestToIntErr(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToInt64Ok(t *testing.T) {
|
||||
source := int64(64)
|
||||
wantValue := int64(64)
|
||||
wantErr := error(nil)
|
||||
|
||||
gotValue, gotErr := kern.ToGoInt64(source, "test")
|
||||
|
||||
if gotErr != nil || gotValue != wantValue {
|
||||
t.Errorf("toInt64(%v, \"test\") gotValue=%v, gotErr=%v -> wantValue=%v, wantErr=%v",
|
||||
source, gotValue, gotErr, wantValue, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestToInt64Err(t *testing.T) {
|
||||
source := uint64(64)
|
||||
wantValue := int64(0)
|
||||
wantErr := errors.New(`test expected integer, got uint64 (64)`)
|
||||
|
||||
gotValue, gotErr := kern.ToGoInt64(source, "test")
|
||||
|
||||
if gotErr.Error() != wantErr.Error() || gotValue != wantValue {
|
||||
t.Errorf("toInt64(%v, \"test\") gotValue=%v, gotErr=%v -> wantValue=%v, wantErr=%v",
|
||||
source, gotValue, gotErr, wantValue, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnyInteger(t *testing.T) {
|
||||
type inputType struct {
|
||||
source any
|
||||
|
||||
Reference in New Issue
Block a user