Tensor_test.cpp 352 字节
Newer Older
D
dzhwinter 已提交
1
#include "gtest/gtest.h"
D
dzhwinter 已提交
2
#include "tensor.h"
D
dzhwinter 已提交
3 4 5 6 7

using namespace paddle;
using namespace paddle::optimizer;

TEST(Tensor, indexer) {
D
dzhwinter 已提交
8
  Tensor t(3);
D
dzhwinter 已提交
9 10 11 12 13 14 15 16 17 18 19
  for (auto i = 0; i < t.size(); ++i) {
    t[i] = i;
  }
  ASSERT_EQ(t[2], 2);
  ASSERT_EQ(t[1], 1);
}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}