11c235774Smrg/*
21c235774Smrg * Copyright (c) 2023, Oracle and/or its affiliates.
31c235774Smrg *
41c235774Smrg * Permission is hereby granted, free of charge, to any person obtaining a
51c235774Smrg * copy of this software and associated documentation files (the "Software"),
61c235774Smrg * to deal in the Software without restriction, including without limitation
71c235774Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
81c235774Smrg * and/or sell copies of the Software, and to permit persons to whom the
91c235774Smrg * Software is furnished to do so, subject to the following conditions:
101c235774Smrg *
111c235774Smrg * The above copyright notice and this permission notice (including the next
121c235774Smrg * paragraph) shall be included in all copies or substantial portions of the
131c235774Smrg * Software.
141c235774Smrg *
151c235774Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
161c235774Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
171c235774Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
181c235774Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
191c235774Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
201c235774Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
211c235774Smrg * DEALINGS IN THE SOFTWARE.
221c235774Smrg */
231c235774Smrg
241c235774Smrg#include <glib.h>
251c235774Smrg
261c235774Smrgstatic void
271c235774SmrgCompareXpmImage(const XpmImage *a, const XpmImage *b)
281c235774Smrg{
291c235774Smrg#if 0
301c235774Smrg    const size_t datasize = sizeof(unsigned int) * a->width * a->height;
311c235774Smrg#endif
321c235774Smrg
331c235774Smrg#define CompareUintFields(f) g_assert_cmpuint(a->f, ==, b->f)
341c235774Smrg
351c235774Smrg    CompareUintFields(width);
361c235774Smrg    CompareUintFields(height);
371c235774Smrg    CompareUintFields(cpp);
381c235774Smrg    CompareUintFields(ncolors);
391c235774Smrg
401c235774Smrg/* this assumes the same character encoding and color ordering, which is only
411c235774Smrg   true in our crafted test cases, not for matching images in the real world */
421c235774Smrg    for (unsigned int i = 0; i < a->ncolors; i++)
431c235774Smrg    {
441c235774Smrg#define CompareStringFields(f) \
451c235774Smrg        g_assert_cmpstr(a->colorTable[i].f, ==, b->colorTable[i].f)
461c235774Smrg
471c235774Smrg        CompareStringFields(string);
481c235774Smrg        CompareStringFields(symbolic);
491c235774Smrg        CompareStringFields(m_color);
501c235774Smrg        CompareStringFields(g4_color);
511c235774Smrg        CompareStringFields(g_color);
521c235774Smrg        CompareStringFields(c_color);
531c235774Smrg    }
541c235774Smrg
551c235774Smrg#if 0 /* this currently fails in image comparison - needs debugging */
561c235774Smrg    for (size_t i = 0; i < datasize; i++)
571c235774Smrg    {
581c235774Smrg        CompareUintFields(data[i]);
591c235774Smrg    }
601c235774Smrg#endif
611c235774Smrg}
62