1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2012 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include <gtest/gtest.h> 25bf215546Sopenharmony_ci#include <GL/gl.h> 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "main/enums.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_cistruct enum_info { 30bf215546Sopenharmony_ci int value; 31bf215546Sopenharmony_ci const char *name; 32bf215546Sopenharmony_ci}; 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ciextern const struct enum_info everything[]; 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ciTEST(EnumStrings, LookUpByNumber) 37bf215546Sopenharmony_ci{ 38bf215546Sopenharmony_ci for (unsigned i = 0; everything[i].name != NULL; i++) { 39bf215546Sopenharmony_ci EXPECT_STREQ(everything[i].name, 40bf215546Sopenharmony_ci _mesa_enum_to_string(everything[i].value)); 41bf215546Sopenharmony_ci } 42bf215546Sopenharmony_ci} 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ciTEST(EnumStrings, LookUpUnknownNumber) 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci EXPECT_STRCASEEQ("0xEEEE", _mesa_enum_to_string(0xEEEE)); 47bf215546Sopenharmony_ci} 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ciconst struct enum_info everything[] = { 50bf215546Sopenharmony_ci /* A core enum, that should take precedence over _EXT and _OES. */ 51bf215546Sopenharmony_ci { 0x0007, "GL_QUADS" }, 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci /* A core enum, that should take precedence over _EXT, _ARB, and _OES. */ 54bf215546Sopenharmony_ci { 0x000a, "GL_LINES_ADJACENCY" }, 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci /* A core enum, that should take precedence over a _BIT. */ 57bf215546Sopenharmony_ci { 0x0100, "GL_ACCUM" }, 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci /* An enum with "_BIT" that shouldn't get stripped out when we drop most 60bf215546Sopenharmony_ci * "*_BIT" enums. 61bf215546Sopenharmony_ci */ 62bf215546Sopenharmony_ci { 0x0d55, "GL_ALPHA_BITS" }, 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci /* An EXT-only extension that we never expect to see show up in ARB/core. 65bf215546Sopenharmony_ci */ 66bf215546Sopenharmony_ci { 0x8062, "GL_REPLACE_EXT" }, 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci /* An extension that made it from vendor to _EXT, but we never expect to 69bf215546Sopenharmony_ci * see go farther. 70bf215546Sopenharmony_ci */ 71bf215546Sopenharmony_ci { 0x80a1, "GL_1PASS_EXT" }, 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci /* A vendor-only extension that we never expect to see show up in 74bf215546Sopenharmony_ci * EXT/ARB/core. 75bf215546Sopenharmony_ci */ 76bf215546Sopenharmony_ci { 0x8503, "GL_COMBINE4_NV" }, 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci /* An extension that got promoted from _EXT to _ARB, but we don't expect to 79bf215546Sopenharmony_ci * see go any further. 80bf215546Sopenharmony_ci */ 81bf215546Sopenharmony_ci { 0x850a, "GL_MODELVIEW1_ARB" }, 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci /* An EXT-only enum that should take precedence over a _BIT. */ 84bf215546Sopenharmony_ci { 0x8000, "GL_ABGR_EXT" }, 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ci /* An unusually-large enum */ 87bf215546Sopenharmony_ci { 0x19262, "GL_RASTER_POSITION_UNCLIPPED_IBM" }, 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci /* Bitfields like GL_SCISSOR_BIT and GL_ALL_ATTRIB_BITS should not appear 90bf215546Sopenharmony_ci * in the table. 91bf215546Sopenharmony_ci */ 92bf215546Sopenharmony_ci { 0x00080000, "0x80000" }, 93bf215546Sopenharmony_ci { 0x000fffff, "0xfffff" }, 94bf215546Sopenharmony_ci { (int)0xffffffff, "0xffffffff" }, 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_ci { 0, NULL } 97bf215546Sopenharmony_ci}; 98