aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java')
-rw-r--r--third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java
new file mode 100644
index 0000000000..2f8e51c630
--- /dev/null
+++ b/third_party/java/jopt-simple/src/test/java/joptsimple/examples/OptionArgumentValueTypeTest.java
@@ -0,0 +1,27 @@
+package joptsimple.examples;
+
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class OptionArgumentValueTypeTest {
+ @Test
+ public void convertsArgumentsToJavaValueTypes() {
+ OptionParser parser = new OptionParser();
+ parser.accepts( "flag" );
+ parser.accepts( "count" ).withRequiredArg().ofType( Integer.class );
+ parser.accepts( "level" ).withOptionalArg().ofType( Level.class );
+
+ OptionSet options = parser.parse( "--count", "3", "--level", "DEBUG" );
+
+ assertTrue( options.has( "count" ) );
+ assertTrue( options.hasArgument( "count" ) );
+ assertEquals( 3, options.valueOf( "count" ) );
+
+ assertTrue( options.has( "level" ) );
+ assertTrue( options.hasArgument( "level" ) );
+ assertEquals( Level.DEBUG, options.valueOf( "level" ) );
+ }
+}