Sha256: 4a9b5cf1cbc3f961a4d29e0fefbb99082cfbf6a35568d25f15923de758e96d1b

Contents?: true

Size: 992 Bytes

Versions: 34

Compression:

Stored size: 992 Bytes

Contents

# encoding: UTF-8

# 100% shorthand
module CodepointTestHelper
  def assert_equal_encoded(expected, encode_mes)
    # Killing a duck because Ruby 1.9 doesn't mix Enumerable into String
    encode_mes = [encode_mes] if encode_mes.is_a?(String)
    encode_mes.each do |encode_me|
      encoded = encode(encode_me)
      actual = encoded.to_ascii
      if expected == actual
        # Let's not retest it
        assert true
      else
        message = "<#{expected.inspect}> expected but was\n<#{actual.inspect}>\n"
        message << "  defined in #{Stringex::Unidecoder.in_yaml_file(encoded)}"
        reporting_class = defined?(Test::Unit::AssertionFailedError) ?
           Test::Unit::AssertionFailedError : ActiveSupport::TestCase::Assertion
        raise reporting_class.new(message)
      end
    end
  end

private
  def encode(codepoint)
    Stringex::Unidecoder.encode(codepoint)
  end

  def which_yaml(codepoint)
    Stringex::Unidecoder.in_yaml_file(encode(codepoint))
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
stringex-2.8.6 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.8.5 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.8.4 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.8.3 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.8.2 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.8.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.7.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.7.0 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.6.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.6.0 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.5.2 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.5.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.5.0 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.4.2 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.4.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.3.0 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.2.2 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.2.1 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.2.0 test/unit/unicode_point_suite/codepoint_test_helper.rb
stringex-2.1.2 test/unit/unicode_point_suite/codepoint_test_helper.rb