Parent

Class/Module Index [+]

Quicksearch

Rex::Parser::Arguments::UnitTest

Public Instance Methods

test_from_s() click to toggle source
# File lib/rex/parser/arguments.rb.ut.rb, line 53
def test_from_s
        args = Rex::Parser::Arguments.from_s(
                "this is a test \"of the emergency pimping\" system \\\"buh lee dat\\\" yup")

        assert_equal(args[0], "this")
        assert_equal(args[3], "test")
        assert_equal(args[4], "of the emergency pimping")
        assert_equal(args[5], "system")
        assert_equal(args[6], "\"buh")
        assert_equal(args[8], "dat\"")
        assert_equal(args[9], "yup")
end
test_parse() click to toggle source
# File lib/rex/parser/arguments.rb.ut.rb, line 9
def test_parse
        args =
                [
                        "-b",
                        "foo",
                        "-c",
                        "-f",
                        "-g",
                        "arg",
                        "none"
                ]

        b = nil
        c = false
        f = false
        g = nil
        none = nil

        Rex::Parser::Arguments.new(
                '-b' => [ true,  "bee" ],
                '-c' => [ false, "cee" ],
                '-f' => [ false, "eff" ],
                '-g' => [ true,  "gee" ]).parse(args) { |opt, idx, val|
                case opt
                        when nil
                                none = val
                        when '-b'
                                b = val
                        when '-c'
                                c = true
                        when '-f'
                                f = true
                        when '-g'
                                g = val
                end
        }

        assert_equal(b, "foo")
        assert_equal(c, true)
        assert_equal(f, true)
        assert_equal(g, "arg")
        assert_equal(none, "none")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.