Blame test/check_tag.c

Packit 7838c8
/* $Id: check_tag.c,v 1.3 2008/04/15 14:19:37 dron Exp $ */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Copyright (c) 2004, Andrey Kiselev  <dron@ak4719.spb.edu>
Packit 7838c8
 *
Packit 7838c8
 * Permission to use, copy, modify, distribute, and sell this software and 
Packit 7838c8
 * its documentation for any purpose is hereby granted without fee, provided
Packit 7838c8
 * that (i) the above copyright notices and this permission notice appear in
Packit 7838c8
 * all copies of the software and related documentation, and (ii) the names of
Packit 7838c8
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
Packit 7838c8
 * publicity relating to the software without the specific, prior written
Packit 7838c8
 * permission of Sam Leffler and Silicon Graphics.
Packit 7838c8
 * 
Packit 7838c8
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
Packit 7838c8
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
Packit 7838c8
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
Packit 7838c8
 * 
Packit 7838c8
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
Packit 7838c8
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
Packit 7838c8
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
Packit 7838c8
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
Packit 7838c8
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
Packit 7838c8
 * OF THIS SOFTWARE.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * TIFF Library
Packit 7838c8
 *
Packit 7838c8
 * Helper testing routines.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
#include "tiffio.h"
Packit 7838c8
Packit 7838c8
int
Packit 7838c8
CheckShortField(TIFF *tif, const ttag_t field, const uint16 value)
Packit 7838c8
{
Packit 7838c8
	uint16 tmp = 123;
Packit 7838c8
Packit 7838c8
	if (!TIFFGetField(tif, field, &tmp)) {
Packit 7838c8
		fprintf (stderr, "Problem fetching tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
	if (tmp != value) {
Packit 7838c8
		fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
Packit 7838c8
	return 0;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
int
Packit 7838c8
CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values)
Packit 7838c8
{
Packit 7838c8
	uint16 tmp[2] = { 123, 456 };
Packit 7838c8
Packit 7838c8
	if (!TIFFGetField(tif, field, tmp, tmp + 1)) {
Packit 7838c8
		fprintf (stderr, "Problem fetching tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
	if (tmp[0] != values[0] || tmp[1] != values[1]) {
Packit 7838c8
		fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
Packit 7838c8
	return 0;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
int
Packit 7838c8
CheckLongField(TIFF *tif, const ttag_t field, const uint32 value)
Packit 7838c8
{
Packit 7838c8
	uint32 tmp = 123;
Packit 7838c8
Packit 7838c8
	if (!TIFFGetField(tif, field, &tmp)) {
Packit 7838c8
		fprintf (stderr, "Problem fetching tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
	if (tmp != value) {
Packit 7838c8
		fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n",
Packit 7838c8
			 (unsigned long) field);
Packit 7838c8
		return -1;
Packit 7838c8
	}
Packit 7838c8
Packit 7838c8
	return 0;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8