Sha256: 9da3559e388b4f80380c5070ea6d408953b053b2b93e1697dae953310f176053

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

require File.join(File.dirname(__FILE__), "test_cli_helper.rb")
require 'rbkb/cli/unhexify'

class TestCliUnhexify < Test::Unit::TestCase
  include CliTest

  def setup
    @cli_class = Rbkb::Cli::Unhexify
    super()
  end

  def test_string_arg
    assert_equal 0, go_with_args(%w(666f6f))
    assert_equal("foo", @stdout_io.string)
  end

  def test_string_arg_with_delim_arg
    assert_equal 0, go_with_args(%w(-d : 66:6f:6f))
    assert_equal("foo", @stdout_io.string)
  end

  def test_stdin
    @stdin_io.write("666f6f") ; @stdin_io.rewind
    assert_equal 0, go_with_args
    assert_equal("foo", @stdout_io.string)
  end

  def test_stdin_with_delim_default_allchars
    @stdin_io.write((0..255).map {|x| x.to_s(16)}.join(' ')); @stdin_io.rewind
    assert_equal 0, go_with_args
    assert_equal((0..255).map {|x| x.chr}.join, @stdout_io.string)
  end


  def test_file_input
    with_testfile do |fname, tf| 
      tf.write "6865785f746573745f666f6f";  tf.close
      assert_equal 0, go_with_args(["-f", fname])
      assert_equal("hex_test_foo", @stdout_io.string)
    end
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
emonti-rbkb-0.6.6 test/test_cli_unhexify.rb
emonti-rbkb-0.6.7 test/test_cli_unhexify.rb
emonti-rbkb-0.6.8 test/test_cli_unhexify.rb
emonti-rbkb-0.6.9.1 test/test_cli_unhexify.rb
emonti-rbkb-0.6.9 test/test_cli_unhexify.rb
rbkb-0.7.2 test/test_cli_unhexify.rb
rbkb-0.7.1 test/test_cli_unhexify.rb
rbkb-0.7.0 test/test_cli_unhexify.rb
rbkb-0.6.12 test/test_cli_unhexify.rb
rbkb-0.6.11 test/test_cli_unhexify.rb
rbkb-0.6.10 test/test_cli_unhexify.rb