EXIF library (libexif) Internals  0.6.24
test-tagtable.c
Go to the documentation of this file.
1 /* test-tagtable.c
2  *
3  * Test various functions that involve the tag table.
4  *
5  * Copyright (c) 2009 Dan Fandrich <dan@coneharvesters.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301 USA.
21  */
22 
23 #include "config.h"
24 #include <libexif/exif-tag.h>
25 #include <stdio.h>
26 #include <string.h>
27 
28 #define VALIDATE(s) if (!(s)) {printf("Test %s FAILED\n", #s); fail=1;}
29 
30 #define TESTBLOCK(t) {int rc = (t); fail |= rc; \
31  if (rc) printf("%s tests FAILED\n", #t);}
32 
33 /* Test exif_tag_get_support_level_in_ifd */
34 static int support_level(void)
35 {
36  int fail = 0;
37 
38  /*
39  * The tag EXIF_TAG_PLANAR_CONFIGURATION support varies greatly between
40  * data types.
41  */
45 
49 
53 
57 
61 
62  /*
63  * The tag EXIF_TAG_YCBCR_POSITIONING support varies greatly between
64  * IFDs
65  */
69 
73 
77 
81 
85 
86 
87  /*
88  * The tag EXIF_TAG_GPS_VERSION_ID has value 0 which should NOT be
89  * treated specially
90  */
94 
98 
102 
106 
107  /* The unused tag 0xffff should NOT be treated specially */
111 
115 
116  /*
117  * The tag EXIF_TAG_DOCUMENT_NAME isn't in the EXIF 2.2 standard but
118  * it exists in the tag table, which causes it to show up as unknown
119  * instead of not recorded.
120  */
124 
128 
129 
130  /*
131  * The tag number for EXIF_TAG_INTEROPERABILITY_INDEX (1) exists in both
132  * IFD Interoperability and IFD GPS (as EXIF_TAG_GPS_LATITUDE_REF) so
133  * there are two entries in the table.
134  */
138 
142 
146 
150 
154 
158 
159  /* The result of an unknown IFD should always be unknown */
163 
167 
168  return fail;
169 }
170 
171 /* Test exif_tag_get_name_in_ifd */
172 static int name(void)
173 {
174  int fail = 0;
175 
176  /*
177  * The tag EXIF_TAG_GPS_VERSION_ID has value 0 which should NOT be
178  * treated specially
179  */
182  "GPSVersionID"))
183 
186 
187  /*
188  * The tag number for EXIF_TAG_INTEROPERABILITY_INDEX (1) exists in both
189  * IFD Interoperability and IFD GPS (as EXIF_TAG_GPS_LATITUDE_REF) so
190  * there are two entries in the table.
191  */
194  "InteroperabilityIndex"))
195 
198  "GPSLatitudeRef"))
199 
200  /* Tag that doesn't appear in an IFD produces a NULL */
203 
204  /* Invalid IFD produces a NULL */
207 
208  return fail;
209 }
210 
211 int
213 {
214  int fail = 0;
215 
217  TESTBLOCK(name())
218 
219  return fail;
220 }
@ EXIF_DATA_TYPE_UNCOMPRESSED_PLANAR
@ EXIF_DATA_TYPE_COMPRESSED
@ EXIF_DATA_TYPE_UNCOMPRESSED_CHUNKY
@ EXIF_DATA_TYPE_UNKNOWN
@ EXIF_DATA_TYPE_UNCOMPRESSED_YCC
@ EXIF_IFD_GPS
Definition: exif-ifd.h:33
@ EXIF_IFD_INTEROPERABILITY
Definition: exif-ifd.h:34
@ EXIF_IFD_EXIF
Definition: exif-ifd.h:32
@ EXIF_IFD_1
Definition: exif-ifd.h:31
@ EXIF_IFD_COUNT
Not a real value, just (max_value + 1).
Definition: exif-ifd.h:35
@ EXIF_IFD_0
Definition: exif-ifd.h:30
const char * exif_tag_get_name_in_ifd(ExifTag tag, ExifIfd ifd)
Return a textual name of the given tag when found in the given IFD.
Definition: exif-tag.c:1038
ExifSupportLevel exif_tag_get_support_level_in_ifd(ExifTag tag, ExifIfd ifd, ExifDataType t)
Return whether the given tag is mandatory or not in the given IFD and data type according to the EXIF...
Definition: exif-tag.c:1256
Handling EXIF tags.
@ EXIF_TAG_EXIF_VERSION
Definition: exif-tag.h:99
@ EXIF_TAG_PLANAR_CONFIGURATION
Definition: exif-tag.h:55
@ EXIF_TAG_YCBCR_POSITIONING
Definition: exif-tag.h:70
@ EXIF_TAG_DOCUMENT_NAME
Definition: exif-tag.h:44
@ EXIF_TAG_INTEROPERABILITY_INDEX
Definition: exif-tag.h:35
#define EXIF_TAG_GPS_VERSION_ID
Definition: exif-tag.h:174
#define EXIF_TAG_GPS_LATITUDE_REF
Definition: exif-tag.h:175
@ EXIF_SUPPORT_LEVEL_UNKNOWN
The meaning of this tag is unknown.
Definition: exif-tag.h:210
@ EXIF_SUPPORT_LEVEL_OPTIONAL
This tag is optional in the given IFD.
Definition: exif-tag.h:219
@ EXIF_SUPPORT_LEVEL_NOT_RECORDED
This tag is not allowed in the given IFD.
Definition: exif-tag.h:213
@ EXIF_SUPPORT_LEVEL_MANDATORY
This tag is mandatory in the given IFD.
Definition: exif-tag.h:216
#define TESTBLOCK(t)
Definition: test-tagtable.c:30
#define VALIDATE(s)
Definition: test-tagtable.c:28
static int name(void)
static int support_level(void)
Definition: test-tagtable.c:34
int main()

libexif Generated by doxygen