Package org.jruby.ext.nkf

Examples of org.jruby.ext.nkf.Command


            runtime = Ruby.newInstance();
        }
    }

    public void testOptParse() throws Exception {
        Command 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());
    }
View Full Code Here


        cmd = RubyNKF.parseOption("-m");
        assertEquals("[[opt: m longOpt: null hasArg: true pattern: [BQN0] value: null]]", cmd.toString());
    }

    public void testOptParseWithArg() throws Exception {
        Command 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"));
    }
View Full Code Here

        assertEquals("[[opt: m longOpt: null hasArg: true pattern: [BQN0] value: B]]", cmd.toString());
        assertTrue(cmd.hasOption("m"));
    }

    public void testMultiShortOptParse() throws Exception {
        Command 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());
    }
View Full Code Here

        Command 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());
    }

    public void testLongOptArg() throws Exception {
        Command 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"));
    }
View Full Code Here

TOP

Related Classes of org.jruby.ext.nkf.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.