MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestTimeZoneOffsetOutOfRange

Function TestTimeZoneOffsetOutOfRange

cel/cel_test.go:2877–2896  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2875}
2876
2877func TestTimeZoneOffsetOutOfRange(t *testing.T) {
2878 env := testEnv(t, Variable("x", TimestampType))
2879 vars := map[string]any{"x": time.Unix(7506, 0).UTC()}
2880 // Offsets whose hour or minute component falls outside a signed HH:MM field
2881 // shift the resolved instant, so they must be rejected at evaluation time.
2882 for _, tz := range []string{"+24:00", "-24:00", "+99:00", "-50:30", "+00:99", "+05:-30"} {
2883 out, err := interpret(t, env, `x.getHours('`+tz+`') >= 0`, vars)
2884 if err == nil {
2885 t.Errorf("getHours(%q) got %v, wanted error", tz, out)
2886 }
2887 }
2888 // A boundary offset within the field ranges keeps resolving.
2889 out, err := interpret(t, env, `x.getHours('23:15')`, vars)
2890 if err != nil {
2891 t.Fatalf("getHours('23:15') failed: %v", err)
2892 }
2893 if out.Equal(types.Int(1)) != types.True {
2894 t.Errorf("getHours('23:15') got %v, wanted 1", out)
2895 }
2896}
2897
2898func TestParserRecursionLimit(t *testing.T) {
2899 testCases := []struct {

Callers

nothing calls this directly

Calls 5

IntTypeAlias · 0.92
interpretFunction · 0.85
testEnvFunction · 0.70
VariableFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected