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

Function TestParseSection

docopt_test.go:1347–1397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1345}
1346
1347func TestParseSection(t *testing.T) {
1348 v := parseSection("usage:", "foo bar fizz buzz")
1349 w := []string{}
1350 if reflect.DeepEqual(v, w) != true {
1351 t.Fail()
1352 }
1353
1354 v = parseSection("usage:", "usage: prog")
1355 w = []string{"usage: prog"}
1356 if reflect.DeepEqual(v, w) != true {
1357 t.Fail()
1358 }
1359
1360 v = parseSection("usage:", "usage: -x\n -y")
1361 w = []string{"usage: -x\n -y"}
1362 if reflect.DeepEqual(v, w) != true {
1363 t.Fail()
1364 }
1365
1366 usage := `usage: this
1367
1368usage:hai
1369usage: this that
1370
1371usage: foo
1372 bar
1373
1374PROGRAM USAGE:
1375 foo
1376 bar
1377usage:
1378` + "\t" + `too
1379` + "\t" + `tar
1380Usage: eggs spam
1381BAZZ
1382usage: pit stop`
1383
1384 v = parseSection("usage:", usage)
1385 w = []string{"usage: this",
1386 "usage:hai",
1387 "usage: this that",
1388 "usage: foo\n bar",
1389 "PROGRAM USAGE:\n foo\n bar",
1390 "usage:\n\ttoo\n\ttar",
1391 "Usage: eggs spam",
1392 "usage: pit stop",
1393 }
1394 if reflect.DeepEqual(v, w) != true {
1395 t.Fail()
1396 }
1397}
1398
1399func TestIssue126DefaultsNotParsedCorrectlyWhenTabs(t *testing.T) {
1400 section := "Options:\n\t--foo=<arg> [default: bar]"

Callers

nothing calls this directly

Calls 1

parseSectionFunction · 0.85

Tested by

no test coverage detected