(t *testing.T)
| 808 | } |
| 809 | |
| 810 | func TestListArgumentMatch(t *testing.T) { |
| 811 | p := newRequired( |
| 812 | newArgument("N", nil), |
| 813 | newArgument("N", nil)) |
| 814 | p.fix() |
| 815 | v, w, x := p.match(&patternList{newArgument("", "1"), |
| 816 | newArgument("", "2")}, nil) |
| 817 | y := patternList{newArgument("N", []string{"1", "2"})} |
| 818 | if v != true || |
| 819 | reflect.DeepEqual(*w, patternList{}) != true || |
| 820 | reflect.DeepEqual(*x, y) != true { |
| 821 | t.Fail() |
| 822 | } |
| 823 | |
| 824 | p = newOneOrMore(newArgument("N", nil)) |
| 825 | p.fix() |
| 826 | v, w, x = p.match(&patternList{newArgument("", "1"), |
| 827 | newArgument("", "2"), newArgument("", "3")}, nil) |
| 828 | y = patternList{newArgument("N", []string{"1", "2", "3"})} |
| 829 | if v != true || |
| 830 | reflect.DeepEqual(*w, patternList{}) != true || |
| 831 | reflect.DeepEqual(*x, y) != true { |
| 832 | t.Fail() |
| 833 | } |
| 834 | |
| 835 | p = newRequired(newArgument("N", nil), |
| 836 | newOneOrMore(newArgument("N", nil))) |
| 837 | p.fix() |
| 838 | v, w, x = p.match(&patternList{ |
| 839 | newArgument("", "1"), |
| 840 | newArgument("", "2"), |
| 841 | newArgument("", "3")}, nil) |
| 842 | y = patternList{newArgument("N", []string{"1", "2", "3"})} |
| 843 | if v != true || |
| 844 | reflect.DeepEqual(*w, patternList{}) != true || |
| 845 | reflect.DeepEqual(*x, y) != true { |
| 846 | t.Fail() |
| 847 | } |
| 848 | |
| 849 | p = newRequired(newArgument("N", nil), |
| 850 | newRequired(newArgument("N", nil))) |
| 851 | p.fix() |
| 852 | v, w, x = p.match(&patternList{ |
| 853 | newArgument("", "1"), |
| 854 | newArgument("", "2")}, nil) |
| 855 | y = patternList{newArgument("N", []string{"1", "2"})} |
| 856 | if v != true || |
| 857 | reflect.DeepEqual(*w, patternList{}) != true || |
| 858 | reflect.DeepEqual(*x, y) != true { |
| 859 | t.Fail() |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | func TestBasicPatternMatching(t *testing.T) { |
| 864 | // ( -a N [ -x Z ] ) |
nothing calls this directly
no test coverage detected