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

Function TestIntervalStart

functional/temporal_test.go:24–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestIntervalStart(t *testing.T) {
25 tests := []struct {
26 name string
27 start int64
28 end int64
29 want int64
30 wantErr bool
31 }{
32 {
33 name: "simple interval",
34 start: 1000,
35 end: 2000,
36 want: 1000,
37 },
38 {
39 name: "point interval",
40 start: 1500,
41 end: 1500,
42 want: 1500,
43 },
44 {
45 name: "negative start",
46 start: -1000,
47 end: 1000,
48 want: -1000,
49 },
50 }
51
52 for _, tc := range tests {
53 t.Run(tc.name, func(t *testing.T) {
54 startConst := ast.Time(tc.start)
55 endConst := ast.Time(tc.end)
56 interval := ast.Pair(&startConst, &endConst)
57
58 result, err := EvalApplyFn(ast.ApplyFn{
59 Function: symbols.IntervalStart,
60 Args: []ast.BaseTerm{interval},
61 }, nil)
62
63 if (err != nil) != tc.wantErr {
64 t.Fatalf("EvalApplyFn() error = %v, wantErr %v", err, tc.wantErr)
65 }
66 if err != nil {
67 return
68 }
69
70 got, err := result.TimeValue()
71 if err != nil {
72 t.Fatalf("result.TimeValue() error = %v", err)
73 }
74 if got != tc.want {
75 t.Errorf("fn:interval:start got %d, want %d", got, tc.want)
76 }
77 })
78 }
79}
80
81func TestIntervalEnd(t *testing.T) {

Callers

nothing calls this directly

Calls 4

TimeFunction · 0.92
PairFunction · 0.92
EvalApplyFnFunction · 0.85
TimeValueMethod · 0.80

Tested by

no test coverage detected