storage_test.cc 727 字节
Newer Older
S
superjom 已提交
1
#include "visualdl/storage/storage.h"
S
superjom 已提交
2 3

#include <gtest/gtest.h>
S
superjom 已提交
4
#include <memory>
S
superjom 已提交
5 6

namespace visualdl {
S
superjom 已提交
7
class StorageTest : public ::testing::Test {
S
superjom 已提交
8
public:
S
superjom 已提交
9 10
  void SetUp() {
    storage.SetDir("./tmp/storage_test");
S
superjom 已提交
11
    storage.meta.cycle = 1;
S
superjom 已提交
12
  }
S
superjom 已提交
13

S
superjom 已提交
14
  Storage storage;
S
superjom 已提交
15 16
};

S
superjom 已提交
17
TEST_F(StorageTest, main) {
S
superjom 已提交
18 19
  storage.AddMode("train");
  storage.AddMode("test");
S
superjom 已提交
20

S
superjom 已提交
21 22
  auto tag0 = storage.AddTablet("tag0");
  auto tag1 = storage.AddTablet("tag1");
S
superjom 已提交
23 24 25
  auto record = tag0.AddRecord();
  auto entry = record.AddData<int>();
  entry.Set(12);
S
superjom 已提交
26 27 28

  StorageReader reader("./tmp/storage_test");
  auto modes = reader.Modes();
S
superjom 已提交
29

S
superjom 已提交
30 31 32
  ASSERT_EQ(modes.size(), 2);
  ASSERT_EQ(modes[0], "train");
  ASSERT_EQ(modes[1], "test");
S
superjom 已提交
33 34 35
}

}  // namespace visualdl