Sha256: 426052ee150a0348c7a2248421c5b6310944d5fc01b0af6733e75bd8805de798

Contents?: true

Size: 1.77 KB

Versions: 53

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path('setup', File.dirname(__FILE__))

module TestLogging

  class TestUtils < Test::Unit::TestCase

    def test_string_shrink
      str = 'this is the foobar string'
      len = str.length

      r = str.shrink(len + 1)
      assert_same str, r

      r = str.shrink(len)
      assert_same str, r

      r = str.shrink(len - 1)
      assert_equal 'this is the...bar string', r

      r = str.shrink(len - 10)
      assert_equal 'this i...string', r

      r = str.shrink(4)
      assert_equal 't...', r

      r = str.shrink(3)
      assert_equal '...', r

      r = str.shrink(0)
      assert_equal '...', r

      assert_raises(ArgumentError) { str.shrink(-1) }

      r = str.shrink(len - 1, '##')
      assert_equal 'this is the##obar string', r

      r = str.shrink(len - 10, '##')
      assert_equal 'this is##string', r

      r = str.shrink(4, '##')
      assert_equal 't##g', r

      r = str.shrink(3, '##')
      assert_equal 't##', r

      r = str.shrink(0, '##')
      assert_equal '##', r
    end

    def test_logger_name
      assert_equal 'Array', Array.logger_name

      # some lines are commented out for compatibility with ruby 1.9

      c = Class.new(Array)
#     assert_equal '', c.name
      assert_equal 'Array', c.logger_name

      meta = class << Array; self; end
#     assert_equal '', meta.name
      assert_equal 'Array', meta.logger_name

      m = Module.new
#     assert_equal '', m.name
      assert_equal 'anonymous', m.logger_name

      c = Class.new(::Logging::Logger)
#     assert_equal '', c.name
      assert_equal 'Logging::Logger', c.logger_name

      meta = class << ::Logging::Logger; self; end
#     assert_equal '', meta.name
      assert_equal 'Logging::Logger', meta.logger_name
    end

  end  # class TestUtils
end  # module TestLogging

Version data entries

53 entries across 45 versions & 4 rubygems

Version Path
logging-2.4.0 test/test_utils.rb
logging-2.3.1 test/test_utils.rb
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_utils.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_utils.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/logging-2.3.0/test/test_utils.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_utils.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_utils.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/logging-2.3.0/test/test_utils.rb
logging-2.3.0 test/test_utils.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/logging-2.2.2/test/test_utils.rb