1/*
2 * Copyright (c) 2023, Oracle and/or its affiliates.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#include <glib.h>
25
26static void
27CompareXpmImage(const XpmImage *a, const XpmImage *b)
28{
29#if 0
30    const size_t datasize = sizeof(unsigned int) * a->width * a->height;
31#endif
32
33#define CompareUintFields(f) g_assert_cmpuint(a->f, ==, b->f)
34
35    CompareUintFields(width);
36    CompareUintFields(height);
37    CompareUintFields(cpp);
38    CompareUintFields(ncolors);
39
40/* this assumes the same character encoding and color ordering, which is only
41   true in our crafted test cases, not for matching images in the real world */
42    for (unsigned int i = 0; i < a->ncolors; i++)
43    {
44#define CompareStringFields(f) \
45        g_assert_cmpstr(a->colorTable[i].f, ==, b->colorTable[i].f)
46
47        CompareStringFields(string);
48        CompareStringFields(symbolic);
49        CompareStringFields(m_color);
50        CompareStringFields(g4_color);
51        CompareStringFields(g_color);
52        CompareStringFields(c_color);
53    }
54
55#if 0 /* this currently fails in image comparison - needs debugging */
56    for (size_t i = 0; i < datasize; i++)
57    {
58        CompareUintFields(data[i]);
59    }
60#endif
61}
62