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

Function TestTimeZoneOffsetOutOfRange

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

Source from the content-addressed store, hash-verified

3077}
3078
3079func TestTimeZoneOffsetOutOfRange(t *testing.T) {
3080 env := testEnv(t, Variable("x", TimestampType))
3081 vars := map[string]any{"x": time.Unix(7506, 0).UTC()}
3082 // Offsets whose hour or minute component falls outside a signed HH:MM field
3083 // shift the resolved instant, so they must be rejected at evaluation time.
3084 for _, tz := range []string{"+24:00", "-24:00", "+99:00", "-50:30", "+00:99", "+05:-30"} {
3085 out, err := interpret(t, env, `x.getHours('`+tz+`') >= 0`, vars)
3086 if err == nil {
3087 t.Errorf("getHours(%q) got %v, wanted error", tz, out)
3088 }
3089 }
3090 // A boundary offset within the field ranges keeps resolving.
3091 out, err := interpret(t, env, `x.getHours('23:15')`, vars)
3092 if err != nil {
3093 t.Fatalf("getHours('23:15') failed: %v", err)
3094 }
3095 if out.Equal(types.Int(1)) != types.True {
3096 t.Errorf("getHours('23:15') got %v, wanted 1", out)
3097 }
3098}
3099
3100func TestParserRecursionLimit(t *testing.T) {
3101 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