1
# -*- coding: utf-8 -*-
3
# ******************************************************************************
5
# Copyright (C) 2010 Olivier Tilloy <olivier@tilloy.net>
7
# This file is part of the pyexiv2 distribution.
9
# pyexiv2 is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License
11
# as published by the Free Software Foundation; either version 2
12
# of the License, or (at your option) any later version.
14
# pyexiv2 is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with pyexiv2; if not, write to the Free Software
21
# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
23
# Author: Olivier Tilloy <olivier@tilloy.net>
25
# ******************************************************************************
29
from pyexiv2.utils import undefined_to_string, string_to_undefined
32
class TestConversions(unittest.TestCase):
34
def test_undefined_to_string(self):
35
self.assertEqual(undefined_to_string("48 50 50 49"), "0221")
36
self.assertEqual(undefined_to_string("48 50 50 49 "), "0221")
37
self.assertRaises(ValueError, undefined_to_string, "")
38
self.assertRaises(ValueError, undefined_to_string, "foo")
39
self.assertRaises(ValueError, undefined_to_string, "48 50 50 49")
41
def test_string_to_undefined(self):
42
self.assertEqual(string_to_undefined("0221"), "48 50 50 49")
43
self.assertEqual(string_to_undefined(""), "")
45
def test_identity(self):
47
self.assertEqual(undefined_to_string(string_to_undefined(value)), value)
49
self.assertEqual(string_to_undefined(undefined_to_string(value)), value)