MCPcopy Create free account
hub / github.com/facebook/time / TestPrepareExpression

Function TestPrepareExpression

fbclock/daemon/math_test.go:90–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestPrepareExpression(t *testing.T) {
91 input := "mean(clockaccuracy, 5) + abs(mean(offset, 5)) + 1.0 * stddev(offset, 4) + 1.0 * stddev(delay, 4) + 1.0 * stddev(freq, 5)"
92 expr, err := prepareExpression(input)
93 require.Nil(t, err)
94
95 parameters := map[string]interface{}{
96 "offset": []float64{1, 2, 3, 4, 5},
97 "delay": []float64{2, 2, 2, 2, 2},
98 "freq": []float64{123, 424, 444, 222, 424},
99 "clockaccuracy": []float64{100, 150, 50, 100, 100},
100 }
101
102 want := 250.1909601786838
103 got, err := expr.Evaluate(parameters)
104 require.Nil(t, err)
105 require.Equal(t, want, got)
106}
107
108func TestPrepareExpressionWrongVari(t *testing.T) {
109 input := "abs(mean(offset, 5)) + 1.0 * stddev(missing, 4)"

Callers

nothing calls this directly

Calls 1

prepareExpressionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…