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

Function TestIntervalEnd

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

Source from the content-addressed store, hash-verified

79}
80
81func TestIntervalEnd(t *testing.T) {
82 tests := []struct {
83 name string
84 start int64
85 end int64
86 want int64
87 wantErr bool
88 }{
89 {
90 name: "simple interval",
91 start: 1000,
92 end: 2000,
93 want: 2000,
94 },
95 {
96 name: "point interval",
97 start: 1500,
98 end: 1500,
99 want: 1500,
100 },
101 }
102
103 for _, tc := range tests {
104 t.Run(tc.name, func(t *testing.T) {
105 startConst := ast.Time(tc.start)
106 endConst := ast.Time(tc.end)
107 interval := ast.Pair(&startConst, &endConst)
108
109 result, err := EvalApplyFn(ast.ApplyFn{
110 Function: symbols.IntervalEnd,
111 Args: []ast.BaseTerm{interval},
112 }, nil)
113
114 if (err != nil) != tc.wantErr {
115 t.Fatalf("EvalApplyFn() error = %v, wantErr %v", err, tc.wantErr)
116 }
117 if err != nil {
118 return
119 }
120
121 got, err := result.TimeValue()
122 if err != nil {
123 t.Fatalf("result.TimeValue() error = %v", err)
124 }
125 if got != tc.want {
126 t.Errorf("fn:interval:end got %d, want %d", got, tc.want)
127 }
128 })
129 }
130}
131
132func TestIntervalDuration(t *testing.T) {
133 tests := []struct {

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