提交 d6d057b4 编写于 作者: Q qijun

change EQ to NEAR for float value

上级 57c27b4e
......@@ -19,9 +19,9 @@ namespace framework {
TEST(EigenDim, From) {
EigenDim<3>::Type ed = EigenDim<3>::From(make_ddim({1, 2, 3}));
EXPECT_EQ(1, ed[0]);
EXPECT_EQ(2, ed[1]);
EXPECT_EQ(3, ed[2]);
ASSERT_EQ(1, ed[0]);
ASSERT_EQ(2, ed[1]);
ASSERT_EQ(3, ed[2]);
}
TEST(Eigen, Tensor) {
......@@ -33,20 +33,17 @@ TEST(Eigen, Tensor) {
EigenTensor<float, 3>::Type et = EigenTensor<float, 3>::From(t);
EXPECT_EQ(1, et.dimension(0));
EXPECT_EQ(2, et.dimension(1));
EXPECT_EQ(3, et.dimension(2));
ASSERT_EQ(1, et.dimension(0));
ASSERT_EQ(2, et.dimension(1));
ASSERT_EQ(3, et.dimension(2));
for (int i = 0; i < 1; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 3; k++) {
EXPECT_EQ((i * 2 + j) * 3 + k, et(i, j, k));
ASSERT_NEAR((i * 2 + j) * 3 + k, et(i, j, k), 1e-6f);
}
}
}
for (int i = 0; i < 1 * 2 * 3; i++) {
EXPECT_EQ(i, et(i));
}
}
TEST(Eigen, VectorFrom) {
......@@ -58,10 +55,10 @@ TEST(Eigen, VectorFrom) {
EigenVector<float>::Type ev = EigenVector<float>::From(t);
EXPECT_EQ(6, ev.dimension(0));
ASSERT_EQ(6, ev.dimension(0));
for (int i = 0; i < 6; i++) {
EXPECT_EQ(i, ev(i));
ASSERT_NEAR(i, ev(i), 1e-6f);
}
}
......@@ -74,10 +71,10 @@ TEST(Eigen, VectorFlatten) {
EigenVector<float>::Type ev = EigenVector<float>::Flatten(t);
EXPECT_EQ(1 * 2 * 3, ev.dimension(0));
ASSERT_EQ(1 * 2 * 3, ev.dimension(0));
for (int i = 0; i < 1 * 2 * 3; i++) {
EXPECT_EQ(i, ev(i));
ASSERT_NEAR(i, ev(i), 1e-6f);
}
}
......@@ -90,12 +87,12 @@ TEST(Eigen, Matrix) {
EigenMatrix<float>::Type em = EigenMatrix<float>::From(t);
EXPECT_EQ(2, em.dimension(0));
EXPECT_EQ(3, em.dimension(1));
ASSERT_EQ(2, em.dimension(0));
ASSERT_EQ(3, em.dimension(1));
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
EXPECT_EQ(i * 3 + j, em(i, j));
ASSERT_NEAR(i * 3 + j, em(i, j), 1e-6f);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册