MCPcopy
hub / github.com/httprunner/httprunner / TestParseFunctionArguments

Function TestParseFunctionArguments

hrp/parser_test.go:557–585  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

555}
556
557func TestParseFunctionArguments(t *testing.T) {
558 testData := []struct {
559 expr string
560 expect interface{}
561 }{
562 {"", []interface{}{}},
563 {"123", []interface{}{123}},
564 {"1.23", []interface{}{1.23}},
565 {"-123", []interface{}{-123}},
566 {"-1.23", []interface{}{-1.23}},
567 {"abc", []interface{}{"abc"}},
568 {"$var", []interface{}{"$var"}},
569 {"1,2", []interface{}{1, 2}},
570 {"1,2.3", []interface{}{1, 2.3}},
571 {"1, -2.3", []interface{}{1, -2.3}},
572 {"1,,2", []interface{}{1, nil, 2}},
573 {" $var1 , 2 ", []interface{}{"$var1", 2}},
574 }
575
576 for _, data := range testData {
577 value, err := parseFunctionArguments(data.expr)
578 if !assert.NoError(t, err) {
579 t.Fatal()
580 }
581 if !assert.Equal(t, data.expect, value) {
582 t.Fatal()
583 }
584 }
585}
586
587func TestParseDataStringWithFunctions(t *testing.T) {
588 variablesMapping := map[string]interface{}{

Callers

nothing calls this directly

Calls 1

parseFunctionArgumentsFunction · 0.85

Tested by

no test coverage detected