MCPcopy Index your code
hub / github.com/google/mangle / TestTimeAdd

Function TestTimeAdd

functional/functional_test.go:1069–1086  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1067}
1068
1069func TestTimeAdd(t *testing.T) {
1070 // 2024-01-15 10:30:00 UTC + 1 hour = 2024-01-15 11:30:00 UTC
1071 baseNanos := int64(1705314600000000000)
1072 hourNanos := int64(3600000000000)
1073
1074 expr := ast.ApplyFn{symbols.TimeAdd, []ast.BaseTerm{
1075 ast.Time(baseNanos),
1076 ast.Duration(hourNanos),
1077 }}
1078 got, err := EvalApplyFn(expr, ast.ConstSubstMap{})
1079 if err != nil {
1080 t.Fatalf("EvalApplyFn(%v) failed with %v", expr, err)
1081 }
1082 want := ast.Time(baseNanos + hourNanos)
1083 if !got.Equals(want) {
1084 t.Errorf("EvalApplyFn(%v) = %v, want %v", expr, got, want)
1085 }
1086}
1087
1088func TestTimeSub(t *testing.T) {
1089 // Subtracting two times returns a duration

Callers

nothing calls this directly

Calls 4

TimeFunction · 0.92
DurationFunction · 0.92
EvalApplyFnFunction · 0.85
EqualsMethod · 0.65

Tested by

no test coverage detected