(t *testing.T)
| 477 | } |
| 478 | |
| 479 | func TestCommandMatch(t *testing.T) { |
| 480 | v, w, x := newCommand("c", false).match( |
| 481 | &patternList{newArgument("", "c")}, nil) |
| 482 | y := patternList{newCommand("c", true)} |
| 483 | if v != true || |
| 484 | reflect.DeepEqual(*w, patternList{}) != true || |
| 485 | reflect.DeepEqual(*x, y) != true { |
| 486 | t.Fail() |
| 487 | } |
| 488 | |
| 489 | v, w, x = newCommand("c", false).match( |
| 490 | &patternList{newOption("-x", "", 0, false)}, nil) |
| 491 | y = patternList{newOption("-x", "", 0, false)} |
| 492 | if v != false || |
| 493 | reflect.DeepEqual(*w, y) != true || |
| 494 | reflect.DeepEqual(*x, patternList{}) != true { |
| 495 | t.Fail() |
| 496 | } |
| 497 | |
| 498 | v, w, x = newCommand("c", false).match( |
| 499 | &patternList{ |
| 500 | newOption("-x", "", 0, false), |
| 501 | newOption("-a", "", 0, false), |
| 502 | newArgument("", "c")}, nil) |
| 503 | y = patternList{newOption("-x", "", 0, false), |
| 504 | newOption("-a", "", 0, false)} |
| 505 | z := patternList{newCommand("c", true)} |
| 506 | if v != true || |
| 507 | reflect.DeepEqual(*w, y) != true || |
| 508 | reflect.DeepEqual(*x, z) != true { |
| 509 | t.Fail() |
| 510 | } |
| 511 | |
| 512 | v, w, x = newEither( |
| 513 | newCommand("add", false), |
| 514 | newCommand("rm", false)).match( |
| 515 | &patternList{newArgument("", "rm")}, nil) |
| 516 | y = patternList{newCommand("rm", true)} |
| 517 | if v != true || |
| 518 | reflect.DeepEqual(*w, patternList{}) != true || |
| 519 | reflect.DeepEqual(*x, y) != true { |
| 520 | t.Fail() |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | func TestOptionalMatch(t *testing.T) { |
| 525 | v, w, x := newOptional(newOption("-a", "", 0, false)).match( |
nothing calls this directly
no test coverage detected