00001 /* test-sorted.c 00002 * 00003 * This test ensures that the ExifTagTable[] array is stored in sorted 00004 * order. If that were not so, then it a binary search of the array would 00005 * not give correct results. 00006 * 00007 * Copyright 2009 Dan Fandrich <dan@coneharvesters.com> 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the 00021 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00022 * Boston, MA 02110-1301 USA 00023 */ 00024 00025 #include <libexif/exif-tag.h> 00026 #include <stdio.h> 00027 00028 int 00029 main (void) 00030 { 00031 int rc = 0; 00032 unsigned int i, num; 00033 ExifTag last = 0, current; 00034 num = exif_tag_table_count() - 1; /* last entry is a NULL terminator */ 00035 for (i=0; i < num; ++i) { 00036 current = exif_tag_table_get_tag(i); 00037 if (current < last) { 00038 printf("Tag 0x%04x in ExifTagTable[] is out of order\n", 00039 current); 00040 rc = 1; 00041 } 00042 if (exif_tag_table_get_name(i) == NULL) { 00043 printf("Tag 0x%04x has a NULL name\n", current); 00044 rc = 1; 00045 } 00046 last = current; 00047 } 00048 00049 return rc; 00050 }