From 621c266f33b82ff4e84d0d3b937564358d3eeb51 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 22 Oct 2011 19:09:20 +0100 Subject: [PATCH] Use 32 bits integers for these tests instead of 64 bits --- test/core/core_func_integer.cpp | 98 ++++++++++++++++----------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/test/core/core_func_integer.cpp b/test/core/core_func_integer.cpp index 2b7008db..3aea6162 100644 --- a/test/core/core_func_integer.cpp +++ b/test/core/core_func_integer.cpp @@ -8,7 +8,6 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// #include -#include #include enum result @@ -19,7 +18,7 @@ enum result STATIC_ASSERT }; -namespace extractField +namespace bitfieldExtract { template struct type @@ -31,48 +30,48 @@ namespace extractField result Result; }; - typedef type typeU64; + typedef type typeU32; - typeU64 const Data64[] = + typeU32 const Data32[] = { - {0xffffffffffffffff, 8, 0, 0x0000000000000000, SUCCESS}, - {0x0000000000000000, 0,64, 0x0000000000000000, SUCCESS}, - {0xffffffffffffffff, 0,64, 0xffffffffffffffff, SUCCESS}, - {0x0f0f0f0f0f0f0f0f, 0,64, 0x0f0f0f0f0f0f0f0f, SUCCESS}, - {0x0000000000000000, 8, 0, 0x0000000000000000, SUCCESS}, - {0x8000000000000000,63, 1, 0x0000000000000001, SUCCESS}, - {0x7fffffffffffffff,63, 1, 0x0000000000000000, SUCCESS}, - {0x0000000000000300, 8, 8, 0x0000000000000003, SUCCESS}, - {0x000000000000ff00, 8, 8, 0x00000000000000ff, SUCCESS}, - {0xfffffffffffffff0, 0, 5, 0x0000000000000010, SUCCESS}, - {0x00000000000000ff, 1, 3, 0x0000000000000007, SUCCESS}, - {0x00000000000000ff, 0, 3, 0x0000000000000007, SUCCESS}, - {0x0000000000000000, 0, 2, 0x0000000000000000, SUCCESS}, - {0xffffffffffffffff, 0, 8, 0x00000000000000ff, SUCCESS}, - {0xffffffff00000000,32,32, 0x00000000ffffffff, SUCCESS}, - {0xfffffffffffffff0, 0, 8, 0x0000000000000000, FAIL}, - {0xffffffffffffffff,32,32, 0x0000000000000000, FAIL}, - //{0xffffffffffffffff,64, 1, 0x0000000000000000, ASSERT}, // Throw an assert - //{0xffffffffffffffff, 0,65, 0x0000000000000000, ASSERT}, // Throw an assert - //{0xffffffffffffffff,33,32, 0x0000000000000000, ASSERT}, // Throw an assert + {0xffffffff, 8, 0, 0x00000000, SUCCESS}, + {0x00000000, 0,32, 0x00000000, SUCCESS}, + {0xffffffff, 0,32, 0xffffffff, SUCCESS}, + {0x0f0f0f0f, 0,32, 0x0f0f0f0f, SUCCESS}, + {0x00000000, 8, 0, 0x00000000, SUCCESS}, + {0x80000000,31, 1, 0x00000001, SUCCESS}, + {0x7fffffff,31, 1, 0x00000000, SUCCESS}, + {0x00000300, 8, 8, 0x00000003, SUCCESS}, + {0x0000ff00, 8, 8, 0x000000ff, SUCCESS}, + {0xfffffff0, 0, 5, 0x00000010, SUCCESS}, + {0x000000ff, 1, 3, 0x00000007, SUCCESS}, + {0x000000ff, 0, 3, 0x00000007, SUCCESS}, + {0x00000000, 0, 2, 0x00000000, SUCCESS}, + {0xffffffff, 0, 8, 0x000000ff, SUCCESS}, + {0xffff0000,16,16, 0x0000ffff, SUCCESS}, + {0xfffffff0, 0, 8, 0x00000000, FAIL}, + {0xffffffff,16,16, 0x00000000, FAIL}, + //{0xffffffff,32, 1, 0x00000000, ASSERT}, // Throw an assert + //{0xffffffff, 0,33, 0x00000000, ASSERT}, // Throw an assert + //{0xffffffff,16,16, 0x00000000, ASSERT}, // Throw an assert }; int test() { - glm::uint32 count = sizeof(Data64) / sizeof(typeU64); + glm::uint count = sizeof(Data32) / sizeof(typeU32); - for(glm::uint32 i = 0; i < count; ++i) + for(glm::uint i = 0; i < count; ++i) { - glm::uint64 Return = glm::bitfieldExtract( - Data64[i].Value, - Data64[i].BitFirst, - Data64[i].BitCount); + glm::uint Return = glm::bitfieldExtract( + Data32[i].Value, + Data32[i].BitFirst, + Data32[i].BitCount); - bool Compare = Data64[i].Return == Return; + bool Compare = Data32[i].Return == Return; - if(Data64[i].Result == SUCCESS && Compare) + if(Data32[i].Result == SUCCESS && Compare) continue; - else if(Data64[i].Result == FAIL && !Compare) + else if(Data32[i].Result == FAIL && !Compare) continue; std::cout << "glm::bitfieldExtract test fail on test " << i << std::endl; @@ -83,7 +82,7 @@ namespace extractField } }//extractField -namespace bitRevert +namespace bitfieldReverse { template struct type @@ -93,32 +92,32 @@ namespace bitRevert result Result; }; - typedef type typeU64; + typedef type typeU32; - typeU64 const Data64[] = + typeU32 const Data32[] = { - {0xffffffffffffffff, 0xffffffffffffffff, SUCCESS}, - {0x0000000000000000, 0x0000000000000000, SUCCESS}, - {0xf000000000000000, 0x000000000000000f, SUCCESS}, + {0xffffffff, 0xffffffff, SUCCESS}, + {0x00000000, 0x00000000, SUCCESS}, + {0xf0000000, 0x0000000f, SUCCESS}, }; int test() { - glm::uint32 count = sizeof(Data64) / sizeof(typeU64); + glm::uint count = sizeof(Data32) / sizeof(typeU32); - for(glm::uint32 i = 0; i < count; ++i) + for(glm::uint i = 0; i < count; ++i) { - glm::uint64 Return = glm::bitfieldReverse( - Data64[i].Value); + glm::uint Return = glm::bitfieldReverse( + Data32[i].Value); - bool Compare = Data64[i].Return == Return; + bool Compare = Data32[i].Return == Return; - if(Data64[i].Result == SUCCESS && Compare) + if(Data32[i].Result == SUCCESS && Compare) continue; - else if(Data64[i].Result == FAIL && !Compare) + else if(Data32[i].Result == FAIL && !Compare) continue; - std::cout << "glm::bitRevert test fail on test " << i << std::endl; + std::cout << "glm::bitfieldReverse test fail on test " << i << std::endl; return 1; } @@ -130,9 +129,8 @@ int main() { int Error = 0; - //GLM_STATIC_ASSERT(sizeof(glm::uint64) == 2, "glm::uint64 isn't a 64 bits type"); + Error += ::bitfieldExtract::test(); + Error += ::bitfieldReverse::test(); - Error += ::extractField::test(); - Error += ::bitRevert::test(); return Error; }