Class: ADSP::Test::String

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/adsp/test/string.rb

Overview

ADSP::Test::String class.

Constant Summary collapse

Target =
Mock::String
Option =
Test::Option
TEXTS =
Common::TEXTS
LARGE_TEXTS =
Common::LARGE_TEXTS
BUFFER_LENGTH_NAMES =
%i[destination_buffer_length].freeze
BUFFER_LENGTH_MAPPING =
{ :destination_buffer_length => :destination_buffer_length }.freeze

Instance Method Summary collapse

Instance Method Details

#get_compatible_decompressor_options(compressor_options, &block) ⇒ Object



90
91
92
# File 'lib/adsp/test/string.rb', line 90

def get_compatible_decompressor_options(compressor_options, &block)
  option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
end

#get_invalid_compressor_options(&block) ⇒ Object




78
79
80
# File 'lib/adsp/test/string.rb', line 78

def get_invalid_compressor_options(&block)
  option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
end

#get_invalid_decompressor_options(&block) ⇒ Object



82
83
84
# File 'lib/adsp/test/string.rb', line 82

def get_invalid_decompressor_options(&block)
  option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
end

#parallel_compressor_options(&block) ⇒ Object



86
87
88
# File 'lib/adsp/test/string.rb', line 86

def parallel_compressor_options(&block)
  Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
end

#test_invalid_argumentsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/adsp/test/string.rb', line 26

def test_invalid_arguments
  Validation::INVALID_STRINGS.each do |invalid_string|
    assert_raises ValidateError do
      target.compress invalid_string
    end

    assert_raises ValidateError do
      target.decompress invalid_string
    end
  end

  get_invalid_compressor_options do |invalid_options|
    assert_raises ValidateError do
      target.compress "", invalid_options
    end
  end

  get_invalid_decompressor_options do |invalid_options|
    assert_raises ValidateError do
      target.decompress "", invalid_options
    end
  end
end

#test_large_textsObject



65
66
67
68
69
70
71
72
73
74
# File 'lib/adsp/test/string.rb', line 65

def test_large_texts
  Common.parallel LARGE_TEXTS do |text|
    compressed_text = target.compress text

    decompressed_text = target.decompress compressed_text
    decompressed_text.force_encoding text.encoding

    assert_equal text, decompressed_text
  end
end

#test_textsObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/adsp/test/string.rb', line 50

def test_texts
  parallel_compressor_options do |compressor_options|
    TEXTS.each do |text|
      compressed_text = target.compress text, compressor_options

      get_compatible_decompressor_options compressor_options do |decompressor_options|
        decompressed_text = target.decompress compressed_text, decompressor_options
        decompressed_text.force_encoding text.encoding

        assert_equal text, decompressed_text
      end
    end
  end
end