9b9264da5cef823d8f91c01f853b3617eff02553
[yaffs-website] / test / PelEntryVersionTest.php
1 <?php
2
3 /**
4  * PEL: PHP Exif Library.
5  * A library with support for reading and
6  * writing all Exif headers in JPEG and TIFF images using PHP.
7  *
8  * Copyright (C) 2004, 2006 Martin Geisler.
9  * Copyright (C) 2017 Johannes Weberhofer
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program in the file COPYING; if not, write to the
23  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24  * Boston, MA 02110-1301 USA
25  */
26
27 use lsolesen\pel\PelEntryVersion;
28 use lsolesen\pel\PelConvert;
29 use PHPUnit\Framework\TestCase;
30
31 class PelEntryVersionTest extends TestCase
32 {
33     function testVersion()
34     {
35         $entry = new PelEntryVersion(42);
36
37         $this->assertEquals($entry->getValue(), 0.0);
38
39         $entry->setValue(2.0);
40         $this->assertEquals($entry->getValue(), 2.0);
41         $this->assertEquals($entry->getText(false), 'Version 2.0');
42         $this->assertEquals($entry->getText(true), '2.0');
43         $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0200');
44
45         $entry->setValue(2.1);
46         $this->assertEquals($entry->getValue(), 2.1);
47         $this->assertEquals($entry->getText(false), 'Version 2.1');
48         $this->assertEquals($entry->getText(true), '2.1');
49         $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0210');
50
51         $entry->setValue(2.01);
52         $this->assertEquals($entry->getValue(), 2.01);
53         $this->assertEquals($entry->getText(false), 'Version 2.01');
54         $this->assertEquals($entry->getText(true), '2.01');
55         $this->assertEquals($entry->getBytes(PelConvert::LITTLE_ENDIAN), '0201');
56     }
57 }