emonti-rbkb 0.6.2.1 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +32 -0
- data/README.rdoc +10 -7
- data/Rakefile +47 -0
- data/bin/feed +5 -0
- data/bin/plugsrv +3 -3
- data/cli_usage.rdoc +44 -9
- data/doctor-bag.jpg +0 -0
- data/lib/rbkb.rb +47 -2
- data/lib/rbkb/cli.rb +8 -6
- data/lib/rbkb/cli/b64.rb +5 -0
- data/lib/rbkb/cli/bgrep.rb +14 -9
- data/lib/rbkb/cli/chars.rb +2 -1
- data/lib/rbkb/cli/crc32.rb +4 -1
- data/lib/rbkb/cli/d64.rb +3 -0
- data/lib/rbkb/cli/dedump.rb +5 -3
- data/lib/rbkb/cli/feed.rb +223 -0
- data/lib/rbkb/cli/hexify.rb +3 -3
- data/lib/rbkb/cli/len.rb +12 -9
- data/lib/rbkb/cli/rstrings.rb +13 -10
- data/lib/rbkb/cli/slice.rb +1 -0
- data/lib/rbkb/cli/telson.rb +21 -57
- data/lib/rbkb/cli/unhexify.rb +2 -6
- data/lib/rbkb/cli/urldec.rb +1 -0
- data/lib/rbkb/cli/urlenc.rb +1 -0
- data/lib/rbkb/extends.rb +41 -6
- data/lib/rbkb/http.rb +20 -0
- data/lib/rbkb/http/base.rb +172 -0
- data/lib/rbkb/http/body.rb +214 -0
- data/lib/rbkb/http/common.rb +74 -0
- data/lib/rbkb/http/headers.rb +356 -0
- data/lib/rbkb/http/parameters.rb +101 -0
- data/lib/rbkb/http/request.rb +58 -0
- data/lib/rbkb/http/response.rb +86 -0
- data/lib/rbkb/plug.rb +3 -3
- data/lib/rbkb/plug/cli.rb +83 -0
- data/lib/rbkb/plug/feed_import.rb +74 -0
- data/lib/rbkb/plug/plug.rb +36 -19
- data/lib/rbkb/plug/unix_domain.rb +75 -0
- data/rbkb.gemspec +38 -0
- data/spec/rbkb_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/test/test_cli_b64.rb +35 -0
- data/test/test_cli_bgrep.rb +137 -0
- data/test/test_cli_blit.rb +11 -0
- data/test/test_cli_chars.rb +21 -0
- data/test/test_cli_crc32.rb +108 -0
- data/test/test_cli_d64.rb +22 -0
- data/test/test_cli_dedump.rb +118 -0
- data/test/test_cli_feed.rb +11 -0
- data/test/test_cli_helper.rb +96 -0
- data/test/test_cli_hexify.rb +63 -0
- data/test/test_cli_len.rb +96 -0
- data/test/test_cli_rstrings.rb +15 -0
- data/test/test_cli_slice.rb +73 -0
- data/test/test_cli_telson.rb +11 -0
- data/test/test_cli_unhexify.rb +43 -0
- data/test/test_cli_urldec.rb +50 -0
- data/test/test_cli_urlenc.rb +44 -0
- data/test/test_cli_xor.rb +71 -0
- data/test/test_helper.rb +5 -0
- data/test/test_http.rb +27 -0
- data/test/test_http_helper.rb +60 -0
- data/test/test_http_request.rb +136 -0
- data/test/test_http_response.rb +222 -0
- data/test/test_rbkb.rb +19 -0
- metadata +127 -21
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
2
|
+
require 'rbkb/cli.rb'
|
3
|
+
|
4
|
+
Rbkb.require_all_libs_relative_to(File.dirname(__FILE__) + "/../lib/rbkb/cli.rb")
|
5
|
+
|
6
|
+
Rbkb::Cli::TESTING = true unless defined? Rbkb::Cli::TESTING
|
7
|
+
|
8
|
+
module CliTest
|
9
|
+
def setup
|
10
|
+
@stdout_io = StringIO.new
|
11
|
+
@stderr_io = StringIO.new
|
12
|
+
@stdin_io = StringIO.new
|
13
|
+
@cli_obj = @cli_class.new(
|
14
|
+
:stdout => @stdout_io,
|
15
|
+
:stderr => @stderr_io,
|
16
|
+
:stdin => @stdin_io
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
## several variations on running a cli command, shouldn't matter which
|
21
|
+
## is used, but we want to test all of them out
|
22
|
+
def go_with_args(argv=[])
|
23
|
+
catch(:exit_err) { catch(:exit_zero) { @cli_obj.go(argv) } }
|
24
|
+
end
|
25
|
+
|
26
|
+
def go_set_args(argv=[])
|
27
|
+
@cli_obj.argv = argv
|
28
|
+
catch(:exit_err) { catch(:exit_zero) { @cli_obj.go } }
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_with_args(argv=[])
|
32
|
+
param = {
|
33
|
+
:stdout => @stdout_io,
|
34
|
+
:stderr => @stderr_io,
|
35
|
+
:stdin => @stdin_io,
|
36
|
+
:argv => argv
|
37
|
+
}
|
38
|
+
catch(:exit_err){ catch(:exit_zero) { @cli_class.run(param) } }
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def with_testfile
|
43
|
+
fname = ".cli_tst_#{rand(0xffffffffffffffff).to_s(16).rjust(16,'0')}.tmp"
|
44
|
+
f=File.open(fname,"w")
|
45
|
+
begin
|
46
|
+
yield(fname.dup, f)
|
47
|
+
ensure
|
48
|
+
f.close unless f.closed?
|
49
|
+
File.delete(fname)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
### These are all basic CLI tests which every derived class should be able
|
54
|
+
### to pass.
|
55
|
+
### They'll be imported into individual TestCli.... suites
|
56
|
+
### along with the standard set up convenience methods above
|
57
|
+
|
58
|
+
# Every command should print usage when -h supplied
|
59
|
+
def test_usage
|
60
|
+
assert_equal 1, go_with_args(%w(-h))
|
61
|
+
assert_match(/^Usage: /, @stderr_io.string )
|
62
|
+
end
|
63
|
+
|
64
|
+
# Every command should exit cleanly when bad arguments are specified
|
65
|
+
def test_bad_argument
|
66
|
+
assert_equal 1, go_with_args(%w(--this_is_really_redonculouslywrong))
|
67
|
+
assert_match(/Error: bad arguments/, @stderr_io.string )
|
68
|
+
end
|
69
|
+
|
70
|
+
# Every command should display version information with -v
|
71
|
+
def test_version_arg
|
72
|
+
assert_equal 0, go_with_args(%w(-v))
|
73
|
+
assert_match(/Ruby BlackBag version #{Rbkb::VERSION}/, @stdout_io.string)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Every command should exit cleanly with a numeric 0/non-zero exit code
|
77
|
+
# when called without arguments.
|
78
|
+
# (and nothing on STDIN for cases when it is expected)
|
79
|
+
def test_clean_exit_with_no_arguments
|
80
|
+
@stdin_io = StringIO.new
|
81
|
+
assert( Numeric === go_with_args() )
|
82
|
+
end
|
83
|
+
|
84
|
+
# Every cli object should support the go() method with obj.argv = [...]
|
85
|
+
def test_vers_go_set_variant
|
86
|
+
assert_equal 0, go_set_args(%w(-v))
|
87
|
+
assert_match(/Ruby BlackBag version #{Rbkb::VERSION}/, @stdout_io.string)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Every cli class should support the 'run([...])' method
|
91
|
+
def test_vers_class_run_variant
|
92
|
+
assert_equal 0, run_with_args(%w(-v))
|
93
|
+
assert_match(/Ruby BlackBag version #{Rbkb::VERSION}/, @stdout_io.string)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
require 'rbkb/cli/hexify'
|
3
|
+
|
4
|
+
class TestCliHexify < Test::Unit::TestCase
|
5
|
+
include CliTest
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli_class = Rbkb::Cli::Hexify
|
9
|
+
super()
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_string_arg
|
13
|
+
assert_equal 0, go_with_args(%w(foo))
|
14
|
+
assert_equal("666f6f\n", @stdout_io.string)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_length_argument
|
18
|
+
assert_equal 0, go_with_args(%w(-l 1 foo))
|
19
|
+
assert_equal("66\n6f\n6f\n", @stdout_io.string)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_bad_length_arguments
|
23
|
+
assert_equal 1, go_with_args(%w(-l 0 foo))
|
24
|
+
assert_match(/must be greater than zero/, @stderr_io.string)
|
25
|
+
assert_equal 1, go_with_args(%w(-l -1 foo))
|
26
|
+
assert_match(/must be greater than zero/, @stderr_io.string)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_string_arg_with_plus
|
30
|
+
assert_equal 0, go_with_args(%w(+ foo))
|
31
|
+
assert_equal("66 6f 6f\n", @stdout_io.string)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_string_arg_with_delim
|
35
|
+
assert_equal 0, go_with_args(%w(-d : foo))
|
36
|
+
assert_equal("66:6f:6f\n", @stdout_io.string)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_string_arg_with_prefix
|
40
|
+
assert_equal 0, go_with_args(%w(-p : foo))
|
41
|
+
assert_equal(":66:6f:6f\n", @stdout_io.string)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_string_arg_with_suffix
|
45
|
+
assert_equal 0, go_with_args(%w(-s : foo))
|
46
|
+
assert_equal("66:6f:6f:\n", @stdout_io.string)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_stdin
|
50
|
+
@stdin_io.write("foo") ; @stdin_io.rewind
|
51
|
+
assert_equal 0, go_with_args
|
52
|
+
assert_equal("666f6f\n", @stdout_io.string)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_file_input
|
56
|
+
with_testfile do |fname, tf|
|
57
|
+
tf.write "hex_test_foo"; tf.close
|
58
|
+
assert_equal 0, go_with_args(["-f", fname])
|
59
|
+
assert_equal("6865785f746573745f666f6f\n", @stdout_io.string)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
require 'rbkb/cli/len'
|
3
|
+
|
4
|
+
class TestCliLen < Test::Unit::TestCase
|
5
|
+
include CliTest
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli_class = Rbkb::Cli::Len
|
9
|
+
super()
|
10
|
+
|
11
|
+
@tst_in = "helu world"
|
12
|
+
@bigtst_in = "A"*65536
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_string_arg
|
16
|
+
assert_equal 0, go_with_args([@tst_in])
|
17
|
+
assert_equal("\x00\x00\x00\x0a" + @tst_in, @stdout_io.string)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_big_string_arg
|
21
|
+
assert_equal 0, go_with_args([@bigtst_in])
|
22
|
+
assert_equal("\x00\x01\x00\x00" + @bigtst_in, @stdout_io.string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_stdin
|
26
|
+
@stdin_io.write(@tst_in) ; @stdin_io.rewind
|
27
|
+
assert_equal 0, go_with_args()
|
28
|
+
assert_equal("\x00\x00\x00\x0a" + @tst_in, @stdout_io.string)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_file_input_flag
|
32
|
+
with_testfile do |fname, tf|
|
33
|
+
tf.write @tst_in; tf.close
|
34
|
+
assert_equal 0, go_with_args(["-f", fname])
|
35
|
+
assert_equal("\x00\x00\x00\x0a" + @tst_in, @stdout_io.string)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_string_arg_swap
|
40
|
+
assert_equal 0, go_with_args(["-x", @tst_in])
|
41
|
+
assert_equal("\x0a\x00\x00\x00" + @tst_in, @stdout_io.string)
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def test_big_string_arg_swap
|
46
|
+
assert_equal 0, go_with_args(["-x", @bigtst_in])
|
47
|
+
assert_equal("\x00\x00\x01\x00" + @bigtst_in, @stdout_io.string)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_big_string_arg_total
|
51
|
+
assert_equal 0, go_with_args(["-t", @bigtst_in])
|
52
|
+
assert_equal("\x00\x01\x00\x04" + @bigtst_in, @stdout_io.string)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_big_string_arg_static_len
|
56
|
+
assert_equal 0, go_with_args(["-l3", @bigtst_in])
|
57
|
+
assert_equal("\x00\x00\x00\x03" + @bigtst_in, @stdout_io.string)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_big_string_arg_static_len_negative
|
61
|
+
assert_equal 0, go_with_args(["-l", "-3", @bigtst_in])
|
62
|
+
assert_equal("\xff\xff\xff\xfd" + @bigtst_in, @stdout_io.string)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_big_string_arg_static_len_negative_short
|
66
|
+
assert_equal 0, go_with_args(["-l", "-3", "-s2", @bigtst_in])
|
67
|
+
assert_equal("\xff\xfd" + @bigtst_in, @stdout_io.string)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_big_string_arg_nudge
|
71
|
+
assert_equal 0, go_with_args(["-n5", @bigtst_in])
|
72
|
+
assert_equal("\x00\x01\x00\x05" + @bigtst_in, @stdout_io.string)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_big_string_arg_byte
|
76
|
+
assert_equal 0, go_with_args(["-s1", @tst_in])
|
77
|
+
assert_equal("\x0a" + @tst_in, @stdout_io.string)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_big_string_arg_byte_wrap
|
81
|
+
assert_equal 0, go_with_args(["-s1", @bigtst_in])
|
82
|
+
assert_equal("\x00" + @bigtst_in, @stdout_io.string)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def test_big_string_arg_short
|
87
|
+
assert_equal 0, go_with_args(["-s2", @tst_in])
|
88
|
+
assert_equal("\x00\x0a" + @tst_in, @stdout_io.string)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_big_string_arg_short_wrap
|
92
|
+
assert_equal 0, go_with_args(["-s2", @bigtst_in])
|
93
|
+
assert_equal("\x00\x00" + @bigtst_in, @stdout_io.string)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
|
3
|
+
# FIXME Finish test cases for rstrings cli
|
4
|
+
|
5
|
+
class TestCliRstrings < Test::Unit::TestCase
|
6
|
+
include CliTest
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@cli_class = Rbkb::Cli::Rstrings
|
10
|
+
super()
|
11
|
+
|
12
|
+
@test_dat = "a\000bc\001def\002gehi\003jklmn\004string 1\005string 2\020\370\f string 3\314string4\221string 5\n\000string 6\r\n\000\000\000\000string 7\000\000w\000i\000d\000e\000s\000t\000r\000i\000n\000g\000\000\000last string\000"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
require 'rbkb/cli/slice'
|
3
|
+
|
4
|
+
class TestCliSlice < Test::Unit::TestCase
|
5
|
+
include CliTest
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli_class = Rbkb::Cli::Slice
|
9
|
+
super()
|
10
|
+
@rawdat = (0..255).map {|x| x.chr}.join
|
11
|
+
@stdin_io.write(@rawdat) ; @stdin_io.rewind
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_stdin
|
15
|
+
assert_equal 0, go_with_args(%w{0})
|
16
|
+
assert_equal @rawdat, @stdout_io.string
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_start_from_end_negative_size
|
20
|
+
assert_equal 0, go_with_args(%w(-- -10))
|
21
|
+
assert_equal(@rawdat[-10..-1], @stdout_io.string)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_file_input_opt
|
25
|
+
with_testfile do |fname, tf|
|
26
|
+
tf.write @rawdat; tf.close
|
27
|
+
assert_equal 0, go_with_args(["-f", fname, "0"])
|
28
|
+
assert_equal(@rawdat, @stdout_io.string)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_bad_start
|
33
|
+
assert_equal 1, go_with_args(%w{foo})
|
34
|
+
assert_match(/invalid start length/i, @stderr_io.string)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_start_from_end_zero
|
38
|
+
assert_equal 0, go_with_args(%w(-r 256))
|
39
|
+
assert_equal("", @stdout_io.string)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_start_from_end_one
|
43
|
+
assert_equal 0, go_with_args(%w(-r 255))
|
44
|
+
assert_equal("\xff", @stdout_io.string)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_start_from_overflow
|
48
|
+
assert_equal 0, go_with_args(%w(-r 2000))
|
49
|
+
assert_equal("", @stdout_io.string)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_range_start_end
|
53
|
+
assert_equal 0, go_with_args(%w(-r 10:20))
|
54
|
+
assert_equal(@rawdat[10..20], @stdout_io.string)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_range_start_and_end
|
58
|
+
assert_equal 0, go_with_args(%w(-r 10:20))
|
59
|
+
assert_equal(@rawdat[10..20], @stdout_io.string)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_range_start_and_end_with_negative_end
|
63
|
+
assert_equal 0, go_with_args(%w(-r 0:-20))
|
64
|
+
assert_equal(@rawdat[0..-20], @stdout_io.string)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def test_range_start_and_end_hex
|
69
|
+
assert_equal 0, go_with_args(%w(-x 0a:14))
|
70
|
+
assert_equal(@rawdat[10..20], @stdout_io.string)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
require 'rbkb/cli/unhexify'
|
3
|
+
|
4
|
+
class TestCliUnhexify < Test::Unit::TestCase
|
5
|
+
include CliTest
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli_class = Rbkb::Cli::Unhexify
|
9
|
+
super()
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_string_arg
|
13
|
+
assert_equal 0, go_with_args(%w(666f6f))
|
14
|
+
assert_equal("foo", @stdout_io.string)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_string_arg_with_delim_arg
|
18
|
+
assert_equal 0, go_with_args(%w(-d : 66:6f:6f))
|
19
|
+
assert_equal("foo", @stdout_io.string)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_stdin
|
23
|
+
@stdin_io.write("666f6f") ; @stdin_io.rewind
|
24
|
+
assert_equal 0, go_with_args
|
25
|
+
assert_equal("foo", @stdout_io.string)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_stdin_with_delim_default_allchars
|
29
|
+
@stdin_io.write((0..255).map {|x| x.to_s(16)}.join(' ')); @stdin_io.rewind
|
30
|
+
assert_equal 0, go_with_args
|
31
|
+
assert_equal((0..255).map {|x| x.chr}.join, @stdout_io.string)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def test_file_input
|
36
|
+
with_testfile do |fname, tf|
|
37
|
+
tf.write "6865785f746573745f666f6f"; tf.close
|
38
|
+
assert_equal 0, go_with_args(["-f", fname])
|
39
|
+
assert_equal("hex_test_foo", @stdout_io.string)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
|
2
|
+
require 'rbkb/cli/urldec'
|
3
|
+
|
4
|
+
class TestCliUrldec < Test::Unit::TestCase
|
5
|
+
include CliTest
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@cli_class = Rbkb::Cli::Urldec
|
9
|
+
super()
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_basic_string_arg
|
13
|
+
assert_equal 0, run_with_args(["foo"])
|
14
|
+
assert_equal "foo", @stdout_io.string
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_basic_string_arg_with_space
|
18
|
+
assert_equal 0, run_with_args(["f%20oo"])
|
19
|
+
assert_equal "f oo", @stdout_io.string
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_basic_string_arg_with_space_plus
|
23
|
+
assert_equal 0, run_with_args(["f+oo"])
|
24
|
+
assert_equal "f oo", @stdout_io.string
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_basic_string_arg_with_space_plus_p_arg
|
28
|
+
assert_equal 0, run_with_args(["-p", "f+oo"])
|
29
|
+
assert_equal "f oo", @stdout_io.string
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_basic_string_arg_with_space_plus_plus_arg
|
33
|
+
assert_equal 0, run_with_args(["--plus", "f+oo"])
|
34
|
+
assert_equal "f oo", @stdout_io.string
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_basic_string_arg_with_space_plus_noplus_arg
|
38
|
+
assert_equal 0, run_with_args(["--no-plus", "f+oo"])
|
39
|
+
assert_equal "f+oo", @stdout_io.string
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_allchars
|
43
|
+
allchars_dec = (0..255).map {|c| c.chr}.join
|
44
|
+
allchars_enc = "%00%01%02%03%04%05%06%07%08%09%0a%0b%0c%0d%0e%0f%10%11%12%13%14%15%16%17%18%19%1a%1b%1c%1d%1e%1f%20%21%22%23%24%25%26%27%28%29%2a%2b%2c-.%2f0123456789%3a%3b%3c%3d%3e%3f%40ABCDEFGHIJKLMNOPQRSTUVWXYZ%5b%5c%5d%5e_%60abcdefghijklmnopqrstuvwxyz%7b%7c%7d~%7f%80%81%82%83%84%85%86%87%88%89%8a%8b%8c%8d%8e%8f%90%91%92%93%94%95%96%97%98%99%9a%9b%9c%9d%9e%9f%a0%a1%a2%a3%a4%a5%a6%a7%a8%a9%aa%ab%ac%ad%ae%af%b0%b1%b2%b3%b4%b5%b6%b7%b8%b9%ba%bb%bc%bd%be%bf%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d7%d8%d9%da%db%dc%dd%de%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f7%f8%f9%fa%fb%fc%fd%fe%ff"
|
45
|
+
assert_equal 0, run_with_args([allchars_enc])
|
46
|
+
assert_equal allchars_dec, @stdout_io.string
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|