[Groonga-commit] ranguba/chupa-text at 536766b [master] Add tests for BOM detection

Back to archive index
Kouhei Sutou null+****@clear*****
Thu Feb 28 14:43:15 JST 2019


Kouhei Sutou	2019-02-28 14:43:15 +0900 (Thu, 28 Feb 2019)

  Revision: 536766bdb18f645c300ca859f8188713688ce55a
  https://github.com/ranguba/chupa-text/commit/536766bdb18f645c300ca859f8188713688ce55a

  Message:
    Add tests for BOM detection

  Modified files:
    test/test-extractor.rb

  Modified: test/test-extractor.rb (+77 -0)
===================================================================
--- test/test-extractor.rb    2019-02-28 14:43:15 +0900 (713b89f)
+++ test/test-extractor.rb    2019-02-28 14:43:15 +0900 (050d38d)
@@ -130,6 +130,69 @@ class TestExtractor < Test::Unit::TestCase
         assert_equal(["こんにちは"], extract(data))
       end
 
+      def test_utf8_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf16_le
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("UTF-16LE")
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf16_le_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "\ufeffこんにちは".encode("UTF-16LE").b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf16_be
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("UTF-16BE")
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf16_be_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "\ufeffこんにちは".encode("UTF-16BE").b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf32_le
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("UTF-32LE")
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf32_le_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "\ufeffこんにちは".encode("UTF-32LE").b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf32_be
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("UTF-32BE")
+        assert_equal(["こんにちは"], extract(data))
+      end
+
+      def test_utf32_be_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "\ufeffこんにちは".encode("UTF-32BE").b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
       def test_cp932
         data = ChupaText::Data.new
         data.mime_type = "text/plain"
@@ -137,12 +200,26 @@ class TestExtractor < Test::Unit::TestCase
         assert_equal(["こんにちは"], extract(data))
       end
 
+      def test_cp932_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("cp932").b
+        assert_equal(["こんにちは"], extract(data))
+      end
+
       def test_euc_jp
         data = ChupaText::Data.new
         data.mime_type = "text/plain"
         data.body = "こんにちは".encode("euc-jp")
         assert_equal(["こんにちは"], extract(data))
       end
+
+      def test_euc_jp_ascii_8bit
+        data = ChupaText::Data.new
+        data.mime_type = "text/plain"
+        data.body = "こんにちは".encode("euc-jp").b
+        assert_equal(["こんにちは"], extract(data))
+      end
     end
   end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190228/fe95dee7/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index