Chromium Code Reviews| Index: test/parse_test.dart |
| diff --git a/test/parse_test.dart b/test/parse_test.dart |
| index 0dd00ba4956449006f339c44bc97b75b41f6360e..dd360af5027e5f77ba359a8a97aced32e453bf15 100644 |
| --- a/test/parse_test.dart |
| +++ b/test/parse_test.dart |
| @@ -199,6 +199,28 @@ void main() { |
| parser.parse([]); |
| expect(a, isEmpty); |
| }); |
| + |
| + test('allowMultiple parses comma-separated strings', () { |
| + var a; |
| + var parser = new ArgParser(); |
| + parser.addOption('a', |
| + allowMultiple: true, callback: (value) => a = value); |
| + |
| + parser.parse(['--a=v,w', '--a=x']); |
| + expect(a, equals(['v', 'w', 'x'])); |
| + }); |
| + |
| + test('allowMultiple with allowed parses comma-separated strings', () { |
| + var a; |
| + var parser = new ArgParser(); |
| + parser.addOption('a', |
| + allowMultiple: true, |
| + allowed: ['v', 'w', 'x'], |
| + callback: (value) => a = value); |
| + |
| + parser.parse(['--a=v,w', '--a=x']); |
| + expect(a, equals(['v', 'w', 'x'])); |
| + }); |
| }); |
| group('abbreviations', () { |
| @@ -287,6 +309,14 @@ void main() { |
| throwsFormat(parser, ['-mprofile']); |
| }); |
| + test('throw if a comma-separated value is not allowed', () { |
| + var parser = new ArgParser(); |
| + parser.addOption('mode', abbr: 'm', allowMultiple: true, |
| + allowed: ['debug', 'release']); |
| + |
| + throwsFormat(parser, ['-mdebug,profile']); |
| + }); |
| + |
|
Bob Nystrom
2015/03/03 17:36:26
Tests for:
","
"a,,b"
",a"
"a,"
nweiz
2015/03/03 20:22:18
I don't think these should throw... multi-value op
|
| test('throw if any but the first is not a flag', () { |
| var parser = new ArgParser(); |
| parser.addFlag('apple', abbr: 'a'); |