mesa: Drop apparently typoed GL_ALL_CLIENT_ATTRIB_BITS.
[mesa.git] / src / mesa / main / tests / enum_strings.cpp
1 /*
2 * Copyright © 2012 Intel Corporation
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 <gtest/gtest.h>
25 #include <GL/gl.h>
26
27 extern "C" {
28 #include "main/enums.h"
29 }
30
31 struct enum_info {
32 int value;
33 const char *name;
34 };
35
36 extern const struct enum_info everything[];
37
38 TEST(EnumStrings, LookUpByNumber)
39 {
40 for (unsigned i = 0; everything[i].name != NULL; i++) {
41 EXPECT_STREQ(everything[i].name,
42 _mesa_enum_to_string(everything[i].value));
43 }
44 }
45
46 TEST(EnumStrings, LookUpUnknownNumber)
47 {
48 EXPECT_STRCASEEQ("0xEEEE", _mesa_enum_to_string(0xEEEE));
49 }
50
51 const struct enum_info everything[] = {
52 /* A core enum, that should take precedence over _EXT and _OES. */
53 { 0x0007, "GL_QUADS" },
54
55 /* A core enum, that should take precedence over _EXT, _ARB, and _OES. */
56 { 0x000a, "GL_LINES_ADJACENCY" },
57
58 /* A core enum, that should take precedence over a _BIT. */
59 { 0x0100, "GL_ACCUM" },
60
61 /* An EXT-only extension that we never expect to see show up in ARB/core.
62 */
63 { 0x8062, "GL_REPLACE_EXT" },
64
65 /* An extension that made it from vendor to _EXT, but we never expect to
66 * see go farther. Disabled for the moment since Mesa doesn't have the XML
67 * for it yet.
68 */
69 /* { 0x80a1, "GL_1PASS_EXT" }, */
70
71 /* A vendor-only extension that we never expect to see show up in
72 * EXT/ARB/core.
73 */
74 { 0x8503, "GL_COMBINE4_NV" },
75
76 /* An extension that got promoted from _EXT to _ARB, but we don't expect to
77 * see go any further.
78 */
79 { 0x850a, "GL_MODELVIEW1_ARB" },
80
81 /* This should be included, but it's value collides with GL_HINT_BIT. The
82 * generator script picks GL_HINT_BIT because it prefers names that lack an
83 * extension suffix.
84 */
85 /* { 0x8000, "GL_ABGR_EXT" }, */
86 { 0x8000, "GL_HINT_BIT" },
87
88 /* An unusually-large enum */
89 { 0x19262, "GL_RASTER_POSITION_UNCLIPPED_IBM" },
90
91 /* A bitmask masquerading as an enum */
92 { 0x00080000, "GL_SCISSOR_BIT" },
93
94 /* A bitfield where Mesa uses a different value from Khronos. */
95 { 0x000fffff, "GL_ALL_ATTRIB_BITS" },
96
97 /* A bitfield in the table, where we fail to return its string anyway! */
98 { (int)0xffffffff, "0xffffffff" },
99
100 { 0, NULL }
101 };