/////////////////////////////////////////////////////////////////////////////////////////////////// // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2010-09-16 // Updated : 2010-09-16 // Licence : This source is under MIT licence // File : test/gtx/bit.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #if(GLM_ARCH != GLM_ARCH_PURE) # include #endif #include #include #include enum result { SUCCESS, FAIL, ASSERT, STATIC_ASSERT }; namespace bitRevert { template struct type { genType Value; genType Return; result Result; }; typedef type typeU64; #if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44)) typeU64 const Data64[] = { {0xffffffffffffffffLLU, 0xffffffffffffffffLLU, SUCCESS}, {0x0000000000000000LLU, 0x0000000000000000LLU, SUCCESS}, {0xf000000000000000LLU, 0x000000000000000fLLU, SUCCESS}, }; #else typeU64 const Data64[] = { {0xffffffffffffffff, 0xffffffffffffffff, SUCCESS}, {0x0000000000000000, 0x0000000000000000, SUCCESS}, {0xf000000000000000, 0x000000000000000f, SUCCESS}, }; #endif int test() { glm::uint32 count = sizeof(Data64) / sizeof(typeU64); for(glm::uint32 i = 0; i < count; ++i) { glm::uint64 Return = glm::bitRevert( Data64[i].Value); bool Compare = Data64[i].Return == Return; if(Data64[i].Result == SUCCESS && Compare) continue; else if(Data64[i].Result == FAIL && !Compare) continue; printf("glm::extractfield test fail on test %d\n", i); return 1; } return 0; } }//bitRevert int main() { int Error(0); Error += ::bitRevert::test(); return Error; }