Tensor_test.cpp 418 字节
Newer Older
D
dzhwinter 已提交
1 2
#include <iostream>
#include "gtest/gtest.h"
D
dzhwinter 已提交
3
#include "tensor.h"
D
dzhwinter 已提交
4 5 6 7 8 9 10 11 12 13 14 15

using namespace paddle;
using namespace paddle::optimizer;

TEST(Tensor, indexer) {
  real* ptr = new real[3];
  Tensor t(ptr, 3);
  for (auto i = 0; i < t.size(); ++i) {
    t[i] = i;
  }
  ASSERT_EQ(t[2], 2);
  ASSERT_EQ(t[1], 1);
D
dzhwinter 已提交
16
  delete ptr;
D
dzhwinter 已提交
17 18 19 20 21 22
}

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