Sha256: 9f3f388936197a0fcbc5aaf2aac9404b156b4b7ed439cccb925f972fb1d833d3

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

#encoding: utf-8
require 'test-unit'
require 'windows/wide_string'

class TC_WideString < Test::Unit::TestCase
  def setup
    @str_english = WideString.new('hello')
    @str_greek   = WideString.new('Ελλάσ')
  end

  def test_length
    assert_equal(10, @str_english.length)
    assert_equal(10, @str_greek.length)
  end

  def test_size
    assert_equal(5, @str_english.size)
    assert_equal(5, @str_greek.size)
  end

  def test_to_multi_english
    assert_respond_to(@str_english, :to_multi)
    assert_equal('hello', @str_english.to_multi)
  end

  def test_to_multi_greek
    if RUBY_VERSION.to_f >= 1.9
      assert_equal('Ελλάσ', @str_greek.to_multi.force_encoding('UTF-8'))
    else
      assert_equal('Ελλάσ', @str_greek.to_multi)
    end
  end

  def test_literal_string_value
    omit_if(RUBY_VERSION.to_f >= 1.9)
    assert_equal("h\000e\000l\000l\000o\000\000\000", @str_english)
    assert_equal("\225\003\273\003\273\003\254\003\303\003\000\000", @str_greek)
  end

  def test_alias_to_s
    assert_respond_to(@str_greek, :to_s)
    assert_true(@str_greek.method(:to_s) == @str_greek.method(:to_multi))
  end

  def test_alias_to_str
    assert_respond_to(@str_greek, :to_str)
    assert_true(@str_greek.method(:to_str) == @str_greek.method(:to_multi))
  end

  def test_alias_inspect
    assert_respond_to(@str_greek, :inspect)
    assert_true(@str_greek.method(:inspect) == @str_greek.method(:to_multi))
  end

  def teardown
    @str_english = nil
    @str_greek   = nil
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
windows-api-0.4.5 test/test_wide_string.rb
windows-pr-1.2.5 vendor/bundle/ruby/2.2.0/gems/windows-api-0.4.4/test/test_wide_string.rb
windows-api-0.4.4 test/test_wide_string.rb
windows-api-0.4.3 test/test_wide_string.rb
windows-api-0.4.2 test/test_wide_string.rb