TEST_F(InputTreeTest, Nesting_Case) {
  InputTree::iterator node = m_pTestee->root();

  for (int i = 0; i < 50; ++i) {
    m_pTestee->enterGroup(node, InputTree::Downward);
    --node;

    Input* input = m_pAlloc->produce("FileSpec", "path1");
    m_pTestee->insert(node, InputTree::Afterward, *input);
    ++node;
  }

  ASSERT_FALSE(node.isRoot());
  ASSERT_FALSE(isGroup(node));
  ASSERT_FALSE(m_pAlloc->empty());
  ASSERT_TRUE(m_pAlloc->size() == 50);
  ASSERT_TRUE(m_pTestee->size() == 100);
}
//===----------------------------------------------------------------------===//
// Testcases
//
TEST_F(InputTreeTest, Basic_operation) {
  std::vector<InputAction*> actions;

  size_t position = 0;
  actions.push_back(new StartGroupAction(position++));
  actions.push_back(new InputFileAction(position++, "path1"));
  actions.push_back(new EndGroupAction(position++));

  std::vector<InputAction*>::iterator action;
  for (action = actions.begin(); action != actions.end(); ++action) {
    (*action)->activate(*m_pBuilder);
    delete *action;
  }

  InputTree::iterator node = m_pTestee->root();
  InputTree::const_iterator const_node = node;
  --node;
  --const_node;

  ASSERT_TRUE(isGroup(node));
  ASSERT_TRUE(isGroup(const_node));
  ASSERT_FALSE(m_pAlloc->empty());
  ASSERT_TRUE(1 == m_pAlloc->size());

  --node;

  m_pTestee->enterGroup(node, InputTree::Downward);

  InputTree::const_iterator const_node2 = node;

  ASSERT_FALSE(node.isRoot());

  ASSERT_FALSE(isGroup(node));
  ASSERT_FALSE(isGroup(const_node2));
  ASSERT_FALSE(m_pAlloc->empty());
  ASSERT_FALSE(m_pAlloc->size() == 0);

  ASSERT_TRUE(m_pTestee->size() == 3);
}
TEST_F(InputTreeTest, forLoop_TEST) {
  InputTree::iterator node = m_pTestee->root();

  Input* input = m_pAlloc->produce("FileSpec", "path1");
  m_pTestee->insert<InputTree::Inclusive>(node, *input);
  InputTree::const_iterator const_node = node;
  --node;

  for (int i = 0; i < 100; ++i) {
    Input* input = m_pAlloc->produce("FileSpec", "path1");
    m_pTestee->insert<InputTree::Inclusive>(node, *input);
    ++node;
  }

  m_pTestee->enterGroup(node, InputTree::Downward);
  --node;

  ASSERT_FALSE(node.isRoot());
  ASSERT_TRUE(isGroup(node));
  ASSERT_FALSE(m_pAlloc->empty());
  ASSERT_FALSE(m_pAlloc->size() == 100);

  ASSERT_TRUE(m_pTestee->size() == 102);
}
Exemple #4
0
//===----------------------------------------------------------------------===//
// non-member functions
//===----------------------------------------------------------------------===//
bool isGroup(const InputTree::iterator& pos) {
  return !pos.hasData() && !pos.isRoot();
}
Exemple #5
0
//===----------------------------------------------------------------------===//
// non-member functions
bool mcld::isGroup(const InputTree::iterator& pos)
{
    return !pos.hasData();
}