Testing String Pattern Matching Utilities in Fluentd
This test suite validates the string utility functionality in Fluentd, focusing on pattern matching and null value handling. It ensures the StringUtil module correctly processes various string inputs and edge cases for the logging framework.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
fluent/fluentd
test/plugin/test_string_util.rb
require_relative '../helper'
require 'fluent/plugin/string_util'
class StringUtilTest < Test::Unit::TestCase
def setup
@null_value_pattern = Regexp.new("^(-|null|NULL)$")
end
sub_test_case 'valid string' do
test 'null string' do
assert_equal Fluent::StringUtil.match_regexp(@null_value_pattern, "null").to_s, "null"
assert_equal Fluent::StringUtil.match_regexp(@null_value_pattern, "NULL").to_s, "NULL"
assert_equal Fluent::StringUtil.match_regexp(@null_value_pattern, "-").to_s, "-"
end
test 'normal string' do
assert_equal Fluent::StringUtil.match_regexp(@null_value_pattern, "fluentd"), nil
end
end
sub_test_case 'invalid string' do
test 'normal string' do
assert_equal Fluent::StringUtil.match_regexp(@null_value_pattern, "\xff"), nil
end
end
end