2014-02-21 02:04:25 -05:00
|
|
|
# coding: US-ASCII
|
2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2019-07-15 01:39:10 -04:00
|
|
|
require_relative 'helper'
|
2014-02-21 02:04:25 -05: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 06:34:01 -04:00
|
|
|
|
2019-03-14 19:12:11 -04:00
|
|
|
def test_level_assignment
|
|
|
|
logger = Logger.new(nil)
|
2019-03-18 06:34:01 -04:00
|
|
|
|
2019-03-14 19:12:11 -04:00
|
|
|
Logger::Severity.constants.each do |level|
|
|
|
|
next if level == :UNKNOWN
|
2019-03-18 06:34:01 -04:00
|
|
|
|
2019-03-14 19:12:11 -04:00
|
|
|
logger.send("#{level.downcase}!")
|
|
|
|
assert(logger.level) == Logger::Severity.const_get(level)
|
|
|
|
end
|
|
|
|
end
|
2014-02-21 02:04:25 -05:00
|
|
|
end
|