Beispiel #1
0
func TestMapSource(t *testing.T) {
	m := map[string]interface{}{
		"A": float64(123),
		"B": float64(456),
	}
	expr := `=A + B`
	testNumber(t, expr, 123+456, exprel.SourceMap(m))
}
Beispiel #2
0
func TestEvaluate(t *testing.T) {
	data := map[string]interface{}{
		"name": "Tim",
	}
	result, err := exprel.Evaluate(`=LOWER(name) & ".jpg"`, exprel.SourceMap(data))
	if err != nil {
		t.Fatal(err)
	}
	filename := result.(string)
	const expecting = "tim.jpg"
	if filename != expecting {
		t.Fatalf("got %s, expecting %s\n", filename, expecting)
	}
}