test.cpp 786 字节
Newer Older
1 2 3 4 5 6
#include "os.h"
#include <gtest/gtest.h>
#include <cassert>
#include <iostream>

#include "taos.h"
7
#include "ttoken.h"
8 9 10 11 12 13 14 15 16 17 18 19 20
#include "tutil.h"

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

// test function in os module
TEST(testCase, parse_time) {
  taos_options(TSDB_OPTION_TIMEZONE, "GMT-8");
  deltaToUtcInitOnce();

  // window: 1500000001000, 1500002000000
H
Haojun Liao 已提交
21
  // pQueryAttr->interval: interval: 86400000, sliding:3600000
22 23 24 25 26 27 28 29 30 31 32 33 34
  int64_t key = 1500000001000;
  SInterval interval = {0};
  interval.interval = 86400000;
  interval.intervalUnit = 'd';
  interval.sliding = 3600000;
  interval.slidingUnit = 'h';

  int64_t s = taosTimeTruncate(key, &interval, TSDB_TIME_PRECISION_MILLI);
  ASSERT_TRUE(s + interval.interval >= key);
}