1848b8605Smrg/*
2848b8605Smrg * Copyright © 2012 Intel Corporation
3848b8605Smrg *
4848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5848b8605Smrg * copy of this software and associated documentation files (the "Software"),
6848b8605Smrg * to deal in the Software without restriction, including without limitation
7848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the
9848b8605Smrg * Software is furnished to do so, subject to the following conditions:
10848b8605Smrg *
11848b8605Smrg * The above copyright notice and this permission notice (including the next
12848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the
13848b8605Smrg * Software.
14848b8605Smrg *
15848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19848b8605Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20848b8605Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21848b8605Smrg * DEALINGS IN THE SOFTWARE.
22848b8605Smrg */
23848b8605Smrg
24848b8605Smrg#include <gtest/gtest.h>
25848b8605Smrg#include <GL/gl.h>
26848b8605Smrg
27848b8605Smrg#include "main/enums.h"
28848b8605Smrg
29848b8605Smrgstruct enum_info {
30848b8605Smrg   int value;
31848b8605Smrg   const char *name;
32848b8605Smrg};
33848b8605Smrg
34848b8605Smrgextern const struct enum_info everything[];
35848b8605Smrg
36848b8605SmrgTEST(EnumStrings, LookUpByNumber)
37848b8605Smrg{
38848b8605Smrg   for (unsigned i = 0; everything[i].name != NULL; i++) {
39848b8605Smrg      EXPECT_STREQ(everything[i].name,
40b8e80941Smrg		   _mesa_enum_to_string(everything[i].value));
41848b8605Smrg   }
42848b8605Smrg}
43848b8605Smrg
44848b8605SmrgTEST(EnumStrings, LookUpUnknownNumber)
45848b8605Smrg{
46b8e80941Smrg   EXPECT_STRCASEEQ("0xEEEE", _mesa_enum_to_string(0xEEEE));
47848b8605Smrg}
48848b8605Smrg
49848b8605Smrgconst struct enum_info everything[] = {
50b8e80941Smrg   /* A core enum, that should take precedence over _EXT and _OES. */
51b8e80941Smrg   { 0x0007, "GL_QUADS" },
52b8e80941Smrg
53b8e80941Smrg   /* A core enum, that should take precedence over _EXT, _ARB, and _OES. */
54b8e80941Smrg   { 0x000a, "GL_LINES_ADJACENCY" },
55b8e80941Smrg
56b8e80941Smrg   /* A core enum, that should take precedence over a _BIT. */
57848b8605Smrg   { 0x0100, "GL_ACCUM" },
58848b8605Smrg
59b8e80941Smrg   /* An enum with "_BIT" that shouldn't get stripped out when we drop most
60b8e80941Smrg    * "*_BIT" enums.
61848b8605Smrg    */
62b8e80941Smrg   { 0x0d55, "GL_ALPHA_BITS" },
63848b8605Smrg
64b8e80941Smrg   /* An EXT-only extension that we never expect to see show up in ARB/core.
65b8e80941Smrg    */
66848b8605Smrg   { 0x8062, "GL_REPLACE_EXT" },
67848b8605Smrg
68b8e80941Smrg   /* An extension that made it from vendor to _EXT, but we never expect to
69b8e80941Smrg    * see go farther.
70848b8605Smrg    */
71b8e80941Smrg   { 0x80a1, "GL_1PASS_EXT" },
72848b8605Smrg
73b8e80941Smrg   /* A vendor-only extension that we never expect to see show up in
74b8e80941Smrg    * EXT/ARB/core.
75b8e80941Smrg    */
76b8e80941Smrg   { 0x8503, "GL_COMBINE4_NV" },
77848b8605Smrg
78b8e80941Smrg   /* An extension that got promoted from _EXT to _ARB, but we don't expect to
79b8e80941Smrg    * see go any further.
80848b8605Smrg    */
81b8e80941Smrg   { 0x850a, "GL_MODELVIEW1_ARB" },
82b8e80941Smrg
83b8e80941Smrg   /* An EXT-only enum that should take precedence over a _BIT. */
84b8e80941Smrg   { 0x8000, "GL_ABGR_EXT" },
85848b8605Smrg
86b8e80941Smrg   /* An unusually-large enum */
87848b8605Smrg   { 0x19262, "GL_RASTER_POSITION_UNCLIPPED_IBM" },
88b8e80941Smrg
89b8e80941Smrg   /* Bitfields like GL_SCISSOR_BIT and GL_ALL_ATTRIB_BITS should not appear
90b8e80941Smrg    * in the table.
91b8e80941Smrg    */
92b8e80941Smrg   { 0x00080000, "0x80000" },
93b8e80941Smrg   { 0x000fffff, "0xfffff" },
94b8e80941Smrg   { (int)0xffffffff, "0xffffffff" },
95b8e80941Smrg
96848b8605Smrg   { 0, NULL }
97848b8605Smrg};
98