Fix cast<> method.
Add vector_type to is_vec, because vector_type is private and it couldn't be used in cast. Besides if not is_vec, you can't expect to find vector_type. The conditional in the cast return type works like if V2 is not a Vec, you can just use V as the vector_type, anyways the first is_vec is false so the whole condition is going to be false anyways, even if it results that V == V.
This commit is contained in:
parent
59d8eb43e7
commit
e64db02ac3
4 changed files with 79 additions and 32 deletions
|
@ -166,6 +166,10 @@ namespace vwr {
|
|||
//Vector Wrapper debug assertions
|
||||
static_assert(not implem::HasOffsetXEnum<VectorWrapperInfo<float>>::value, "Should return false");
|
||||
static_assert(implem::HasOffsetXEnum<VectorWrapperInfo<SimpleVector2>>::value, "Should return true");
|
||||
static_assert(implem::have_compat_offsets<SimpleVector3, PaddedVector3>::value, "Should be true");
|
||||
static_assert(implem::have_compat_layout<SimpleVector3, PaddedVector3>::value, "Should be true");
|
||||
static_assert(implem::is_vec<pvec3>::value, "Should be true");
|
||||
static_assert(implem::is_vec<svec3>::value, "Should be true");
|
||||
} //namespace vwr
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#include "sample_vectors.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
void test_svec3 (const vwr::svec3& parVec, float parX, float parY, float parZ) {
|
||||
EXPECT_EQ(parVec.x(), parX);
|
||||
EXPECT_EQ(parVec.y(), parY);
|
||||
EXPECT_EQ(parVec.z(), parZ);
|
||||
}
|
||||
|
||||
TEST(vwr, conversion) {
|
||||
using namespace vwr;
|
||||
|
||||
|
@ -12,5 +18,29 @@ TEST(vwr, conversion) {
|
|||
static_assert(std::is_same<decltype(s2), svec2>::value, "Expecting svec2");
|
||||
EXPECT_EQ(s2.x(), s.x());
|
||||
EXPECT_EQ(s2.y(), 1.0f);
|
||||
|
||||
auto s3 = s2.xyn(2.0f);
|
||||
EXPECT_EQ(s3.x(), s2.x());
|
||||
EXPECT_EQ(s3.y(), s2.y());
|
||||
EXPECT_EQ(s3.z(), 2.0f);
|
||||
|
||||
const auto s3_copy(s3);
|
||||
EXPECT_EQ(s3_copy, s3);
|
||||
}
|
||||
|
||||
{
|
||||
svec3 s3(1.0f);
|
||||
mvec3 m3(s3);
|
||||
EXPECT_EQ(m3.x(), 1.0f);
|
||||
EXPECT_EQ(m3.y(), 1.0f);
|
||||
EXPECT_EQ(m3.z(), 1.0f);
|
||||
EXPECT_EQ(m3.data().x, 1.0f);
|
||||
EXPECT_EQ(m3.data().y, 1.0f);
|
||||
EXPECT_EQ(m3.data().z, 1.0f);
|
||||
}
|
||||
|
||||
{
|
||||
pvec3 p3(1.0f, 2.0f, 3.0f);
|
||||
test_svec3(p3.cast<svec3>(), p3.x(), p3.y(), p3.z());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue