MCPcopy
hub / github.com/google/mangle / TestTimeSub

Function TestTimeSub

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

Source from the content-addressed store, hash-verified

1086}
1087
1088func TestTimeSub(t *testing.T) {
1089 // Subtracting two times returns a duration
1090 t1 := int64(1705318200000000000) // 2024-01-15 11:30:00 UTC
1091 t2 := int64(1705314600000000000) // 2024-01-15 10:30:00 UTC
1092
1093 expr := ast.ApplyFn{symbols.TimeSub, []ast.BaseTerm{
1094 ast.Time(t1),
1095 ast.Time(t2),
1096 }}
1097 got, err := EvalApplyFn(expr, ast.ConstSubstMap{})
1098 if err != nil {
1099 t.Fatalf("EvalApplyFn(%v) failed with %v", expr, err)
1100 }
1101 want := ast.Duration(t1 - t2)
1102 if !got.Equals(want) {
1103 t.Errorf("EvalApplyFn(%v) = %v, want %v", expr, got, want)
1104 }
1105}
1106
1107func TestTimeFormat(t *testing.T) {
1108 // Format a time using RFC3339

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