resultBufferTest.cpp 1.5 KB
Newer Older
H
hjxilinx 已提交
1 2 3 4
#include <gtest/gtest.h>
#include <cassert>
#include <iostream>

H
Haojun Liao 已提交
5
#include "qResultbuf.h"
H
hjxilinx 已提交
6 7 8 9 10 11 12
#include "taos.h"
#include "tsdb.h"

namespace {
// simple test
void simpleTest() {
  SDiskbasedResultBuf* pResultBuf = NULL;
H
Haojun Liao 已提交
13
  int32_t ret = createDiskbasedResultBuffer(&pResultBuf, 1000, 64, 1024, 4, NULL);
H
hjxilinx 已提交
14 15 16 17 18 19 20
  
  int32_t pageId = 0;
  int32_t groupId = 0;
  
  tFilePage* pBufPage = getNewDataBuf(pResultBuf, groupId, &pageId);
  ASSERT_TRUE(pBufPage != NULL);
  
H
Haojun Liao 已提交
21
  ASSERT_EQ(getResBufSize(pResultBuf), 1024);
H
hjxilinx 已提交
22 23
  
  SIDList list = getDataBufPagesIdList(pResultBuf, groupId);
H
Haojun Liao 已提交
24
  ASSERT_EQ(taosArrayGetSize(list), 1);
H
hjxilinx 已提交
25
  ASSERT_EQ(getNumOfResultBufGroupId(pResultBuf), 1);
H
Haojun Liao 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

  releaseResBufPage(pResultBuf, pBufPage);

  tFilePage* pBufPage1 = getNewDataBuf(pResultBuf, groupId, &pageId);

  tFilePage* t = getResBufPage(pResultBuf, pageId);
  assert(t == pBufPage1);

  tFilePage* pBufPage2 = getNewDataBuf(pResultBuf, groupId, &pageId);
  tFilePage* t1 = getResBufPage(pResultBuf, pageId);
  assert(t1 == pBufPage2);

  tFilePage* pBufPage3 = getNewDataBuf(pResultBuf, groupId, &pageId);
  tFilePage* t2 = getResBufPage(pResultBuf, pageId);
  assert(t2 == pBufPage3);

  tFilePage* pBufPage4 = getNewDataBuf(pResultBuf, groupId, &pageId);
  tFilePage* t3 = getResBufPage(pResultBuf, pageId);
  assert(t3 == pBufPage4);

  tFilePage* pBufPage5 = getNewDataBuf(pResultBuf, groupId, &pageId);
  tFilePage* t4 = getResBufPage(pResultBuf, pageId);
  assert(t4 == pBufPage5);

H
hjxilinx 已提交
50
  destroyResultBuf(pResultBuf, NULL);
H
hjxilinx 已提交
51 52 53 54 55 56
}
} // namespace

TEST(testCase, resultBufferTest) {
  simpleTest();
}