]>
Commit | Line | Data |
---|---|---|
8414a40c VZ |
1 | |
2 | /* | |
3 | * Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu> | |
4 | * | |
5 | * Permission to use, copy, modify, distribute, and sell this software and | |
6 | * its documentation for any purpose is hereby granted without fee, provided | |
7 | * that (i) the above copyright notices and this permission notice appear in | |
8 | * all copies of the software and related documentation, and (ii) the names of | |
9 | * Sam Leffler and Silicon Graphics may not be used in any advertising or | |
10 | * publicity relating to the software without the specific, prior written | |
11 | * permission of Sam Leffler and Silicon Graphics. | |
12 | * | |
13 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, | |
14 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY | |
15 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | |
16 | * | |
17 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR | |
18 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, | |
19 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
20 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF | |
21 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
22 | * OF THIS SOFTWARE. | |
23 | */ | |
24 | ||
25 | /* | |
26 | * TIFF Library | |
27 | * | |
80ed523f | 28 | * Helper testing routines. |
8414a40c VZ |
29 | */ |
30 | ||
31 | #include "tiffio.h" | |
32 | ||
33 | int | |
80ed523f | 34 | CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) |
8414a40c | 35 | { |
80ed523f | 36 | uint16 tmp = 123; |
8414a40c VZ |
37 | |
38 | if (!TIFFGetField(tif, field, &tmp)) { | |
39 | fprintf (stderr, "Problem fetching tag %lu.\n", | |
40 | (unsigned long) field); | |
41 | return -1; | |
42 | } | |
43 | if (tmp != value) { | |
44 | fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n", | |
45 | (unsigned long) field); | |
46 | return -1; | |
47 | } | |
48 | ||
49 | return 0; | |
50 | } | |
51 | ||
52 | int | |
80ed523f | 53 | CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) |
8414a40c | 54 | { |
80ed523f VZ |
55 | uint16 tmp[2] = { 123, 456 }; |
56 | ||
57 | if (!TIFFGetField(tif, field, tmp, tmp + 1)) { | |
58 | fprintf (stderr, "Problem fetching tag %lu.\n", | |
59 | (unsigned long) field); | |
60 | return -1; | |
61 | } | |
62 | if (tmp[0] != values[0] || tmp[1] != values[1]) { | |
63 | fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n", | |
64 | (unsigned long) field); | |
65 | return -1; | |
66 | } | |
67 | ||
68 | return 0; | |
69 | } | |
70 | ||
71 | int | |
72 | CheckLongField(TIFF *tif, const ttag_t field, const uint32 value) | |
73 | { | |
74 | uint32 tmp = 123; | |
8414a40c VZ |
75 | |
76 | if (!TIFFGetField(tif, field, &tmp)) { | |
77 | fprintf (stderr, "Problem fetching tag %lu.\n", | |
78 | (unsigned long) field); | |
79 | return -1; | |
80 | } | |
81 | if (tmp != value) { | |
82 | fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n", | |
83 | (unsigned long) field); | |
84 | return -1; | |
85 | } | |
86 | ||
87 | return 0; | |
88 | } | |
89 | ||
90 |