Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: test/usage_test.dart

Issue 1145413002: Add support for separators. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Code review changes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/usage_test.dart
diff --git a/test/usage_test.dart b/test/usage_test.dart
index e7f3e4779a0738d23bbd1cf204cd945f72435948..31f4679606fcc6dda36f097082052b9cc1f21255 100644
--- a/test/usage_test.dart
+++ b/test/usage_test.dart
@@ -205,6 +205,77 @@ void main() {
--[no-]third The third flag
''');
});
+
+ group("separators", () {
+ test("separates options where it's placed", () {
+ var parser = new ArgParser();
+ parser.addFlag('zebra', help: 'First');
+ parser.addSeparator('Primate:');
+ parser.addFlag('monkey', help: 'Second');
+ parser.addSeparator('Marsupial:');
+ parser.addFlag('wombat', help: 'Third');
+
+ validateUsage(parser, '''
+ --[no-]zebra First
+
+ Primate:
+ --[no-]monkey Second
+
+ Marsupial:
+ --[no-]wombat Third
+ ''');
+ });
+
+ test("doesn't add extra newlines after a multiline option", () {
+ var parser = new ArgParser();
+ parser.addFlag('zebra', help: 'Multi\nline');
+ parser.addSeparator('Primate:');
+ parser.addFlag('monkey', help: 'Second');
+
+ validateUsage(parser, '''
+ --[no-]zebra Multi
+ line
+
+ Primate:
+ --[no-]monkey Second
+ ''');
+ });
+
+ test("doesn't add newlines if it's the first component", () {
+ var parser = new ArgParser();
+ parser.addSeparator('Equine:');
+ parser.addFlag('zebra', help: 'First');
+
+ validateUsage(parser, '''
+ Equine:
+ --[no-]zebra First
+ ''');
+ });
+
+ test("doesn't add trailing newlines if it's the last component", () {
+ var parser = new ArgParser();
+ parser.addFlag('zebra', help: 'First');
+ parser.addSeparator('Primate:');
+
+ validateUsage(parser, '''
+ --[no-]zebra First
+
+ Primate:
+ ''');
+ });
+
+ test("adds a newline after another separator", () {
+ var parser = new ArgParser();
+ parser.addSeparator('First');
+ parser.addSeparator('Second');
+
+ validateUsage(parser, '''
+ First
+
+ Second
+ ''');
+ });
+ });
});
}
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698