2014-02-21 11:04:25 +04:00
|
|
|
# coding: US-ASCII
|
2015-12-16 08:07:31 +03:00
|
|
|
# frozen_string_literal: false
|
2019-07-15 08:39:10 +03:00
|
|
|
require_relative 'helper'
|
2014-02-21 11:04:25 +04:00
|
|
|
|
|
|
|
class TestLoggerSeverity < Test::Unit::TestCase
|
|
|
|
def test_enum
|
|
|
|
logger_levels = Logger.constants
|
|
|
|
levels = ["WARN", "UNKNOWN", "INFO", "FATAL", "DEBUG", "ERROR"]
|
|
|
|
Logger::Severity.constants.each do |level|
|
|
|
|
assert(levels.include?(level.to_s))
|
|
|
|
assert(logger_levels.include?(level))
|
|
|
|
end
|
|
|
|
assert_equal(levels.size, Logger::Severity.constants.size)
|
|
|
|
end
|
2019-03-18 13:34:01 +03:00
|
|
|
|
2019-03-15 02:12:11 +03:00
|
|
|
def test_level_assignment
|
|
|
|
logger = Logger.new(nil)
|
2019-03-18 13:34:01 +03:00
|
|
|
|
2019-03-15 02:12:11 +03:00
|
|
|
Logger::Severity.constants.each do |level|
|
|
|
|
next if level == :UNKNOWN
|
2019-03-18 13:34:01 +03:00
|
|
|
|
2019-03-15 02:12:11 +03:00
|
|
|
logger.send("#{level.downcase}!")
|
|
|
|
assert(logger.level) == Logger::Severity.const_get(level)
|
|
|
|
end
|
|
|
|
end
|
2014-02-21 11:04:25 +04:00
|
|
|
end
|