MCPcopy Create free account
hub / github.com/docopt/docopt.go / TestFileTestcases

Function TestFileTestcases

docopt_test.go:1408–1433  ·  view source on GitHub ↗

conf file based test cases

(t *testing.T)

Source from the content-addressed store, hash-verified

1406
1407// conf file based test cases
1408func TestFileTestcases(t *testing.T) {
1409 filenames := []string{"testcases.docopt", "test_golang.docopt"}
1410 for _, filename := range filenames {
1411 raw, err := ioutil.ReadFile(filename)
1412 if err != nil {
1413 t.Fatal(err)
1414 }
1415
1416 tests, err := parseTest(raw)
1417 if err != nil {
1418 t.Fatal(err)
1419 }
1420 for _, c := range tests {
1421 result, err := Parse(c.doc, c.argv, true, "", false, false)
1422 if _, ok := err.(*UserError); c.userError && !ok {
1423 // expected a user-error
1424 t.Error("testcase:", c.id, "result:", result)
1425 } else if _, ok := err.(*UserError); !c.userError && ok {
1426 // unexpected user-error
1427 t.Error("testcase:", c.id, "error:", err, "result:", result)
1428 } else if reflect.DeepEqual(c.expect, result) != true {
1429 t.Error("testcase:", c.id, "result:", result, "expect:", c.expect)
1430 }
1431 }
1432 }
1433}
1434
1435type testcase struct {
1436 id int

Callers

nothing calls this directly

Calls 3

parseTestFunction · 0.85
ParseFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected