Class: ADSP::Test::File
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- ADSP::Test::File
- Defined in:
- lib/adsp/test/file.rb
Overview
ADSP::Test::File class.
Constant Summary collapse
- Target =
Mock::File
- Option =
Test::Option
- SOURCE_PATH =
Common::SOURCE_PATH
- ARCHIVE_PATH =
Common::ARCHIVE_PATH
- TEXTS =
Common::TEXTS
- LARGE_TEXTS =
Common::LARGE_TEXTS
- BUFFER_LENGTH_NAMES =
i[source_buffer_length destination_buffer_length].freeze
- BUFFER_LENGTH_MAPPING =
{ :source_buffer_length => :destination_buffer_length, :destination_buffer_length => :source_buffer_length } .freeze
Instance Method Summary collapse
- #get_compatible_decompressor_options(compressor_options, &block) ⇒ Object
-
#get_invalid_compressor_options(&block) ⇒ Object
—–.
- #get_invalid_decompressor_options(&block) ⇒ Object
- #parallel_compressor_options(&block) ⇒ Object
- #test_invalid_arguments ⇒ Object
- #test_large_texts ⇒ Object
- #test_texts ⇒ Object
Instance Method Details
#get_compatible_decompressor_options(compressor_options, &block) ⇒ Object
115 116 117 |
# File 'lib/adsp/test/file.rb', line 115 def (, &block) option. , BUFFER_LENGTH_MAPPING, &block end |
#get_invalid_compressor_options(&block) ⇒ Object
103 104 105 |
# File 'lib/adsp/test/file.rb', line 103 def (&block) option. BUFFER_LENGTH_NAMES, &block end |
#get_invalid_decompressor_options(&block) ⇒ Object
107 108 109 |
# File 'lib/adsp/test/file.rb', line 107 def (&block) option. BUFFER_LENGTH_NAMES, &block end |
#parallel_compressor_options(&block) ⇒ Object
111 112 113 |
# File 'lib/adsp/test/file.rb', line 111 def (&block) Common. option.(BUFFER_LENGTH_NAMES), &block end |
#test_invalid_arguments ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/adsp/test/file.rb', line 32 def test_invalid_arguments Validation::INVALID_STRINGS.each do |invalid_path| assert_raises ValidateError do target.compress invalid_path, ARCHIVE_PATH end assert_raises ValidateError do target.compress SOURCE_PATH, invalid_path end assert_raises ValidateError do target.decompress invalid_path, SOURCE_PATH end assert_raises ValidateError do target.decompress ARCHIVE_PATH, invalid_path end end do || assert_raises ValidateError do target.compress SOURCE_PATH, ARCHIVE_PATH, end end do || assert_raises ValidateError do target.decompress ARCHIVE_PATH, SOURCE_PATH, end end end |
#test_large_texts ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/adsp/test/file.rb', line 85 def test_large_texts Common.parallel LARGE_TEXTS do |text, worker_index| source_path = Common.get_path SOURCE_PATH, worker_index archive_path = Common.get_path ARCHIVE_PATH, worker_index ::File.write source_path, text, :mode => "wb" target.compress source_path, archive_path target.decompress archive_path, source_path decompressed_text = ::File.read source_path, :mode => "rb" decompressed_text.force_encoding text.encoding assert_equal text, decompressed_text end end |
#test_texts ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/adsp/test/file.rb', line 64 def test_texts do |, worker_index| source_path = Common.get_path SOURCE_PATH, worker_index archive_path = Common.get_path ARCHIVE_PATH, worker_index TEXTS.each do |text| ::File.write source_path, text, :mode => "wb" target.compress source_path, archive_path, do || target.decompress archive_path, source_path, decompressed_text = ::File.read source_path, :mode => "rb" decompressed_text.force_encoding text.encoding assert_equal text, decompressed_text end end end end |