changeset 348:b1cb68189284

Regression: -rf should accept mixed-case constants as well.
author shade
date Tue, 14 Jan 2014 15:54:38 +0400
parents 2e5bf03c85a8
children 574c426233cf
files jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java	Tue Jan 14 14:39:26 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/options/CommandLineOptions.java	Tue Jan 14 15:54:38 2014 +0400
@@ -226,7 +226,7 @@
 
             if (set.has(optResultFormat)) {
                 try {
-                    resultFormat = Optional.of(ResultFormatType.valueOf(optResultFormat.value(set)));
+                    resultFormat = Optional.of(ResultFormatType.valueOf(optResultFormat.value(set).toUpperCase()));
                 } catch (IllegalArgumentException iae) {
                     throw new CommandLineOptionException(iae.getMessage(), iae);
                 }
--- a/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java	Tue Jan 14 14:39:26 2014 +0400
+++ b/jmh-core/src/test/java/org/openjdk/jmh/runner/options/TestOptions.java	Tue Jan 14 15:54:38 2014 +0400
@@ -113,6 +113,24 @@
     }
 
     @Test
+    public void testResultFormats_UC() throws Exception {
+        for (ResultFormatType type : ResultFormatType.values()) {
+            CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toUpperCase());
+            Options builder = new OptionsBuilder().resultFormat(type).build();
+            Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat());
+        }
+    }
+
+    @Test
+    public void testResultFormats_LC() throws Exception {
+        for (ResultFormatType type : ResultFormatType.values()) {
+            CommandLineOptions cmdLine = new CommandLineOptions("-rf", type.toString().toLowerCase());
+            Options builder = new OptionsBuilder().resultFormat(type).build();
+            Assert.assertEquals(builder.getResultFormat(), cmdLine.getResultFormat());
+        }
+    }
+
+    @Test
     public void testResultFormats_Default() throws Exception {
         Assert.assertEquals(EMPTY_BUILDER.getResultFormat(), EMPTY_CMDLINE.getResultFormat());
     }