diff options
-rwxr-xr-x | test.rb | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -9,9 +9,19 @@ class MahoroTestCase < Test::Unit::TestCase @m = Mahoro.new end + # Different versions of libmagic may generate different values. + # So far, we have seen: + # - ASCII C program text + # - C source, ASCII text + def assert_c_text(buf) + assert_match(/\bC\b/, buf, "contains the letter C") + assert_match(/\s/, buf, "contains spaces") + assert_match(/(?:source|text)/, buf, "is source or text") + end + def test_file @m.flags = Mahoro::NONE - assert_equal('ASCII C program text', @m.file('mahoro.c')) + assert_c_text(@m.file('mahoro.c')) end def test_mime_file @@ -28,14 +38,13 @@ class MahoroTestCase < Test::Unit::TestCase def test_buffer @m.flags = Mahoro::NONE - assert_equal('ASCII C program text', - @m.buffer(File.read('mahoro.c'))) + assert_c_text(@m.buffer(File.read('mahoro.c'))) end def test_buffer_string_convert tmp = File.read('mahoro.c') buf = Struct.new(:to_str).new(tmp) - assert_equal('ASCII C program text', @m.buffer(buf)) + assert_c_text(@m.buffer(buf)) end def test_buffer_invalid |