diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-04-04 22:46:10 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-04-04 22:46:10 +0000 |
commit | 92e549dfb5f19125f4b6131937b738eee5b046c7 (patch) | |
tree | 9a50f834f8e7f258ca9be6735f2247c514bcd876 | |
parent | 7027149ddd5d2cafb8483e88fcfd9e5b49ed141f (diff) | |
download | mahoro-92e549dfb5f19125f4b6131937b738eee5b046c7.tar.gz |
test: be more flexible with Mahoro::NONE matches
Different versions/installations of libmagic may return different results.
-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 |