Exemple #1
0
 public void testOptParse() throws Exception {
   RubyNKF.CmdCommand cmd = RubyNKF.parseOption("-j");
   assertEquals("[[opt: j longOpt: jis hasArg: false pattern: null value: null]]", cmd.toString());
   cmd = RubyNKF.parseOption("--hiragana");
   assertEquals(
       "[[opt: h1 longOpt: hiragana hasArg: false pattern: null value: null]]", cmd.toString());
   cmd = RubyNKF.parseOption("-j --hiragana");
   assertEquals(
       "[[opt: j longOpt: jis hasArg: false pattern: null value: null], [opt: h1 longOpt: hiragana hasArg: false pattern: null value: null]]",
       cmd.toString());
   cmd = RubyNKF.parseOption("-Z");
   assertEquals(
       "[[opt: Z longOpt: null hasArg: true pattern: [0-3] value: null]]", cmd.toString());
   assertTrue(cmd.hasOption("Z"));
   cmd = RubyNKF.parseOption("-Z0");
   assertEquals("[[opt: Z longOpt: null hasArg: true pattern: [0-3] value: 0]]", cmd.toString());
   cmd = RubyNKF.parseOption("-Z1");
   assertEquals("[[opt: Z longOpt: null hasArg: true pattern: [0-3] value: 1]]", cmd.toString());
   cmd = RubyNKF.parseOption("--unix");
   assertEquals(
       "[[opt: null longOpt: unix hasArg: false pattern: null value: null]]", cmd.toString());
   assertTrue(cmd.hasOption("unix"));
   cmd = RubyNKF.parseOption("-m");
   assertEquals(
       "[[opt: m longOpt: null hasArg: true pattern: [BQN0] value: null]]", cmd.toString());
 }
Exemple #2
0
 public void testLongOptArg() throws Exception {
   RubyNKF.CmdCommand cmd = RubyNKF.parseOption("--ic=ISO-2022-JP");
   assertEquals(
       "[[opt: null longOpt: ic hasArg: true pattern: ic=(.*) value: ISO-2022-JP]]",
       cmd.toString());
   assertTrue(cmd.hasOption("ic"));
   cmd = RubyNKF.parseOption("-w16 --oc=utf-8");
   assertEquals(
       "[[opt: w longOpt: null hasArg: true pattern: [0-9][0-9] value: 16], [opt: null longOpt: oc hasArg: true pattern: oc=(.*) value: utf-8]]",
       cmd.toString());
   assertTrue(cmd.hasOption("w"));
   assertEquals("16", cmd.getOptionValue("w"));
   assertTrue(cmd.hasOption("oc"));
   assertEquals("utf-8", cmd.getOptionValue("oc"));
 }
Exemple #3
0
 public void testOptParseWithArg() throws Exception {
   RubyNKF.CmdCommand cmd = RubyNKF.parseOption("-L");
   assertEquals(
       "[[opt: L longOpt: null hasArg: true pattern: [uwm] value: null]]", cmd.toString());
   cmd = RubyNKF.parseOption("-Lu");
   assertEquals("[[opt: L longOpt: null hasArg: true pattern: [uwm] value: u]]", cmd.toString());
   assertTrue(cmd.hasOption("L"));
   cmd = RubyNKF.parseOption("-f60-");
   assertEquals(
       "[[opt: f longOpt: null hasArg: true pattern: [0-9]+-[0-9]* value: 60-]]", cmd.toString());
   assertTrue(cmd.hasOption("f"));
   cmd = RubyNKF.parseOption("-f60-30");
   assertEquals(
       "[[opt: f longOpt: null hasArg: true pattern: [0-9]+-[0-9]* value: 60-30]]",
       cmd.toString());
   assertTrue(cmd.hasOption("f"));
   cmd = RubyNKF.parseOption("-mB");
   assertEquals("[[opt: m longOpt: null hasArg: true pattern: [BQN0] value: B]]", cmd.toString());
   assertTrue(cmd.hasOption("m"));
 }
Exemple #4
0
 public void testMultiShortOptParse() throws Exception {
   RubyNKF.CmdCommand cmd = RubyNKF.parseOption("-jSbw32");
   assertEquals(
       "[[opt: j longOpt: jis hasArg: false pattern: null value: null], [opt: S longOpt: sjis-input hasArg: false pattern: null value: null], [opt: b longOpt: null hasArg: false pattern: null value: null], [opt: w longOpt: null hasArg: true pattern: [0-9][0-9] value: 32]]",
       cmd.toString());
 }