mirror of
https://github.com/g-truc/glm.git
synced 2024-11-22 17:04:35 +00:00
Added usubBorrow tests
This commit is contained in:
parent
fcfc56d5e3
commit
2179695e02
@ -116,7 +116,7 @@ namespace glm
|
||||
Borrow = mix(vecType<uint, P>(1), vecType<uint, P>(0), greaterThanEqual(x, y));
|
||||
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))));
|
||||
return mix(XgeY, YgeX, y >= x);
|
||||
return mix(XgeY, YgeX, greaterThanEqual(y, x));
|
||||
}
|
||||
|
||||
// umulExtended
|
||||
|
@ -8,6 +8,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/integer.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <iostream>
|
||||
|
||||
enum result
|
||||
@ -225,14 +226,58 @@ namespace usubBorrow
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::uint x = 16;
|
||||
glm::uint y = 17;
|
||||
glm::uint Borrow = 0;
|
||||
glm::uint Result = glm::usubBorrow(x, y, Borrow);
|
||||
|
||||
{
|
||||
glm::uint x = 16;
|
||||
glm::uint y = 17;
|
||||
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;
|
||||
}
|
||||
|
||||
}//namespace usubBorrow
|
||||
|
||||
int main()
|
||||
@ -241,6 +286,7 @@ int main()
|
||||
|
||||
std::cout << "sizeof(glm::uint64): " << sizeof(glm::detail::uint64) << std::endl;
|
||||
|
||||
Error += ::usubBorrow::test();
|
||||
Error += ::bitfieldExtract::test();
|
||||
Error += ::bitfieldReverse::test();
|
||||
Error += ::findMSB::test();
|
||||
|
Loading…
Reference in New Issue
Block a user