File: test_invalid_byte_sequence_in_utf8.rb

package info (click to toggle)
ruby-mini-exiftool 2.9.0-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 688 kB
  • sloc: ruby: 2,616; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# -- encoding: utf-8 --
require 'helpers_for_test'
require 'json'

# Thanks to Chris Salzberg (aka shioyama) and
# Robert May (aka robotmay) for precious hints

class TestInvalidByteSequenceInUtf8 < TestCase

  def setup
    @json = File.read(File.dirname(__FILE__) + '/data/invalid_byte_sequence_in_utf8.json')
  end

  def test_invalid_byte_sequence_gets_unconverted_value_with_invalid_encoding
    assert_nothing_raised do
      mini_exiftool = MiniExiftool.from_json(@json)
      assert_equal 1561, mini_exiftool.color_balance_unknown.size
    end
  end

  def test_replace_invalid_chars
    assert_nothing_raised do
      mini_exiftool = MiniExiftool.from_json(@json, :replace_invalid_chars => '')
      assert_equal 1036, mini_exiftool.color_balance_unknown.size
    end
  end

end