int-itrator: new iterator over integer ranges

This commit is contained in:
2026-05-01 17:23:06 +02:00
parent 78871641d0
commit 6c5e9db34b
2 changed files with 163 additions and 0 deletions
+26
View File
@@ -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