1b8bc0d8aSopenharmony_ci/* test-sorted.c 2b8bc0d8aSopenharmony_ci * 3b8bc0d8aSopenharmony_ci * This test ensures that the ExifTagTable[] array is stored in sorted 4b8bc0d8aSopenharmony_ci * order. If that were not so, then it a binary search of the array would 5b8bc0d8aSopenharmony_ci * not give correct results. 6b8bc0d8aSopenharmony_ci * 7b8bc0d8aSopenharmony_ci * Copyright 2009 Dan Fandrich <dan@coneharvesters.com> 8b8bc0d8aSopenharmony_ci * 9b8bc0d8aSopenharmony_ci * This library is free software; you can redistribute it and/or 10b8bc0d8aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 11b8bc0d8aSopenharmony_ci * License as published by the Free Software Foundation; either 12b8bc0d8aSopenharmony_ci * version 2 of the License, or (at your option) any later version. 13b8bc0d8aSopenharmony_ci * 14b8bc0d8aSopenharmony_ci * This library is distributed in the hope that it will be useful, 15b8bc0d8aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 16b8bc0d8aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17b8bc0d8aSopenharmony_ci * Lesser General Public License for more details. 18b8bc0d8aSopenharmony_ci * 19b8bc0d8aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 20b8bc0d8aSopenharmony_ci * License along with this library; if not, write to the 21b8bc0d8aSopenharmony_ci * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22b8bc0d8aSopenharmony_ci * Boston, MA 02110-1301 USA 23b8bc0d8aSopenharmony_ci */ 24b8bc0d8aSopenharmony_ci 25b8bc0d8aSopenharmony_ci#include <libexif/exif-tag.h> 26b8bc0d8aSopenharmony_ci#include <stdio.h> 27b8bc0d8aSopenharmony_ci 28b8bc0d8aSopenharmony_ciint 29b8bc0d8aSopenharmony_cimain (void) 30b8bc0d8aSopenharmony_ci{ 31b8bc0d8aSopenharmony_ci int rc = 0; 32b8bc0d8aSopenharmony_ci unsigned int i, num; 33b8bc0d8aSopenharmony_ci ExifTag last = 0, current; 34b8bc0d8aSopenharmony_ci num = exif_tag_table_count() - 1; /* last entry is a NULL terminator */ 35b8bc0d8aSopenharmony_ci for (i=0; i < num; ++i) { 36b8bc0d8aSopenharmony_ci current = exif_tag_table_get_tag(i); 37b8bc0d8aSopenharmony_ci if (current < last) { 38b8bc0d8aSopenharmony_ci printf("Tag 0x%04x in ExifTagTable[] is out of order\n", 39b8bc0d8aSopenharmony_ci current); 40b8bc0d8aSopenharmony_ci rc = 1; 41b8bc0d8aSopenharmony_ci } 42b8bc0d8aSopenharmony_ci if (exif_tag_table_get_name(i) == NULL) { 43b8bc0d8aSopenharmony_ci printf("Tag 0x%04x has a NULL name\n", current); 44b8bc0d8aSopenharmony_ci rc = 1; 45b8bc0d8aSopenharmony_ci } 46b8bc0d8aSopenharmony_ci last = current; 47b8bc0d8aSopenharmony_ci } 48b8bc0d8aSopenharmony_ci 49b8bc0d8aSopenharmony_ci return rc; 50b8bc0d8aSopenharmony_ci} 51