Sha256: 49420a52209cb3a88498cbd79131aeb00b45b28235175db41e390b7502cb8f4e
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
##################################################################### # test_binary.rb # # Test case for the File.binary? method. You should run this test # via the 'rake test_binary' task. ##################################################################### require 'rubygems' require 'test-unit' require 'ptools' class TC_Ptools_Binary < Test::Unit::TestCase def self.startup if File::ALT_SEPARATOR @@bin_file = File.join(ENV['windir'], 'notepad.exe') else @@bin_file = '/bin/ls' end @@dirname = File.dirname(__FILE__) end def setup @txt_file = File.join(@@dirname, 'txt', 'english.txt') @uni_file = File.join(@@dirname, 'txt', 'korean.txt') @png_file = File.join(@@dirname, 'img', 'test.png') @jpg_file = File.join(@@dirname, 'img', 'test.jpg') @gif_file = File.join(@@dirname, 'img', 'test.gif') end test "File.binary? basic functionality" do assert_respond_to(File, :binary?) assert_nothing_raised{ File.binary?(@txt_file) } end test "File.binary? returns true for binary files" do assert_true(File.binary?(@@bin_file)) end test "File.binary? returns false for text files" do assert_false(File.binary?(@txt_file)) assert_false(File.binary?(@uni_file)) end test "File.binary? returns false for image files" do assert_false(File.binary?(@png_file)) assert_false(File.binary?(@jpg_file)) assert_false(File.binary?(@gif_file)) end test "File.binary? raises an error if the file cannot be found" do assert_raise_kind_of(SystemCallError){ File.binary?('bogus') } end test "File.binary? only accepts one argument" do assert_raise_kind_of(ArgumentError){ File.binary?(@txt_file, @@bin_file) } end def teardown @txt_file = nil @uni_file = nil @png_file = nil @jpg_file = nil @gif_file = nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ptools-1.3.3 | test/test_binary.rb |
ptools-1.3.2 | test/test_binary.rb |
ptools-1.3.2-universal-mingw32 | test/test_binary.rb |