You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
88 lines
1.9 KiB
88 lines
1.9 KiB
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
// 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 <glm/gtx/bit.hpp> |
|
#include <glm/gtc/type_precision.hpp> |
|
|
|
#if(GLM_ARCH != GLM_ARCH_PURE) |
|
# include <glm/detail/intrinsic_integer.hpp> |
|
#endif |
|
|
|
#include <vector> |
|
#include <ctime> |
|
#include <cstdio> |
|
|
|
enum result |
|
{ |
|
SUCCESS, |
|
FAIL, |
|
ASSERT, |
|
STATIC_ASSERT |
|
}; |
|
|
|
namespace bitRevert |
|
{ |
|
template <typename genType> |
|
struct type |
|
{ |
|
genType Value; |
|
genType Return; |
|
result Result; |
|
}; |
|
|
|
typedef type<glm::uint64> 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; |
|
}
|
|
|