Added usubBorrow tests

This commit is contained in:
Christophe Riccio 2014-10-21 01:40:42 +02:00
parent fcfc56d5e3
commit 2179695e02
2 changed files with 53 additions and 7 deletions

View File

@ -116,7 +116,7 @@ namespace glm
Borrow = mix(vecType<uint, P>(1), vecType<uint, P>(0), greaterThanEqual(x, y)); Borrow = mix(vecType<uint, P>(1), vecType<uint, P>(0), greaterThanEqual(x, y));
vecType<uint, P> const YgeX(y - x); vecType<uint, P> const YgeX(y - x);
vecType<uint, P> const XgeY(vecType<uint32, P>((static_cast<int64>(1) << static_cast<int64>(32)) + (vecType<int64, P>(y) - vecType<int64, P>(x)))); vecType<uint, P> const XgeY(vecType<uint32, P>((static_cast<int64>(1) << static_cast<int64>(32)) + (vecType<int64, P>(y) - vecType<int64, P>(x))));
return mix(XgeY, YgeX, y >= x); return mix(XgeY, YgeX, greaterThanEqual(y, x));
} }
// umulExtended // umulExtended

View File

@ -8,6 +8,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/integer.hpp> #include <glm/integer.hpp>
#include <glm/gtc/vec1.hpp>
#include <iostream> #include <iostream>
enum result enum result
@ -225,14 +226,58 @@ namespace usubBorrow
{ {
int Error(0); int Error(0);
glm::uint x = 16; {
glm::uint y = 17; glm::uint x = 16;
glm::uint Borrow = 0; glm::uint y = 17;
glm::uint Result = glm::usubBorrow(x, y, Borrow); glm::uint Borrow = 0;
glm::uint Result = glm::usubBorrow(x, y, Borrow);
Error += Borrow == 1 ? 0 : 1;
Error += Result == 1 ? 0 : 1;
}
{
glm::uvec1 x(16);
glm::uvec1 y(17);
glm::uvec1 Borrow(0);
glm::uvec1 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec1(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec1(1))) ? 0 : 1;
}
{
glm::uvec2 x(16);
glm::uvec2 y(17);
glm::uvec2 Borrow(0);
glm::uvec2 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec2(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec2(1))) ? 0 : 1;
}
{
glm::uvec3 x(16);
glm::uvec3 y(17);
glm::uvec3 Borrow(0);
glm::uvec3 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec3(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec3(1))) ? 0 : 1;
}
{
glm::uvec4 x(16);
glm::uvec4 y(17);
glm::uvec4 Borrow(0);
glm::uvec4 Result(glm::usubBorrow(x, y, Borrow));
Error += glm::all(glm::equal(Borrow, glm::uvec4(1))) ? 0 : 1;
Error += glm::all(glm::equal(Result, glm::uvec4(1))) ? 0 : 1;
}
return Error; return Error;
} }
}//namespace usubBorrow }//namespace usubBorrow
int main() int main()
@ -241,6 +286,7 @@ int main()
std::cout << "sizeof(glm::uint64): " << sizeof(glm::detail::uint64) << std::endl; std::cout << "sizeof(glm::uint64): " << sizeof(glm::detail::uint64) << std::endl;
Error += ::usubBorrow::test();
Error += ::bitfieldExtract::test(); Error += ::bitfieldExtract::test();
Error += ::bitfieldReverse::test(); Error += ::bitfieldReverse::test();
Error += ::findMSB::test(); Error += ::findMSB::test();