13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program Test Executor 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------ 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Test case. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "xeTestCase.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace xe 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getTestCaseTypeName (TestCaseType caseType) 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (caseType) 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TESTCASETYPE_SELF_VALIDATE: return "SelfValidate"; 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TESTCASETYPE_CAPABILITY: return "Capability"; 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TESTCASETYPE_ACCURACY: return "Accuracy"; 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case TESTCASETYPE_PERFORMANCE: return "Performance"; 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline int getFirstComponentLength (const char* path) 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compLen = 0; 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (path[compLen] != 0 && path[compLen] != '.') 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compLen++; 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return compLen; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool compareNameToPathComponent (const char* name, const char* path, int compLen) 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pos = 0; pos < compLen; pos++) 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (name[pos] != path[pos]) 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (name[compLen] != 0) 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void splitPath (const char* path, std::vector<std::string>& components) 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string pathStr (path); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compStart = 0; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pos = 0; pos < (int)pathStr.length(); pos++) 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pathStr[pos] == '.') 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry components.push_back(pathStr.substr(compStart, pos-compStart)); 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compStart = pos+1; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(compStart < (int)pathStr.length()); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry components.push_back(pathStr.substr(compStart)); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestNode 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestNode::TestNode (TestGroup* parent, TestNodeType nodeType, const char* name, const char* desc) 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_parent (parent) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_nodeType (nodeType) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_name (name) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_description (desc) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_parent) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Verify that the name is unique. 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (parent->m_childNames.find(name) != parent->m_childNames.end()) 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw Error(std::string("Duplicate node '") + name + "' in '" + parent->getFullPath()); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_parent->m_children.push_back(this); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_parent->m_childNames.insert(name); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestNode::getFullPath (std::string& dst) const 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.clear(); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int nameLen = 0; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestNode* curNode = this; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (;;) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nameLen += (int)curNode->m_name.length(); 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(curNode->m_parent); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (curNode->m_parent->getNodeType() != TESTNODETYPE_ROOT) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nameLen += 1; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curNode = curNode->m_parent; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.resize(nameLen); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curNode = this; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int pos = nameLen; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (;;) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::copy(curNode->m_name.begin(), curNode->m_name.end(), dst.begin()+(pos-curNode->m_name.length())); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pos -= (int)curNode->m_name.length(); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(curNode->m_parent); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (curNode->m_parent->getNodeType() != TESTNODETYPE_ROOT) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[--pos] = '.'; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curNode = curNode->m_parent; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst TestNode* TestNode::find (const char* path) const 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_nodeType == TESTNODETYPE_ROOT) 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Don't need to consider current node. 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return static_cast<const TestGroup*>(this)->findChildNode(path); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check if first component matches this node. 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compLen = getFirstComponentLength(path); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry XE_CHECK(compLen > 0); 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (compareNameToPathComponent(getName(), path, compLen)) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (path[compLen] == 0) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return this; 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (getNodeType() == TESTNODETYPE_GROUP) 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return static_cast<const TestGroup*>(this)->findChildNode(path + compLen + 1); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestNode* TestNode::find (const char* path) 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return const_cast<TestNode*>(const_cast<const TestNode*>(this)->find(path)); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestGroup 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestGroup::TestGroup (TestGroup* parent, TestNodeType nodeType, const char* name, const char* description) 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestNode(parent, nodeType, name, description) 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(nodeType == TESTNODETYPE_GROUP || nodeType == TESTNODETYPE_ROOT); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!parent == (nodeType == TESTNODETYPE_ROOT)); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestGroup::~TestGroup (void) 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (std::vector<TestNode*>::iterator i = m_children.begin(); i != m_children.end(); i++) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete *i; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestGroup* TestGroup::createGroup (const char* name, const char* description) 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return new TestGroup(this, TESTNODETYPE_GROUP, name, description); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase* TestGroup::createCase (TestCaseType caseType, const char* name, const char* description) 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return TestCase::createAsChild(this, caseType, name, description); 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst TestNode* TestGroup::findChildNode (const char* path) const 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int compLen = getFirstComponentLength(path); 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry XE_CHECK(compLen > 0); 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Try to find matching children. 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestNode* matchingNode = DE_NULL; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<TestNode*>::const_iterator iter = m_children.begin(); iter != m_children.end(); iter++) 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (compareNameToPathComponent((*iter)->getName(), path, compLen)) 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry matchingNode = *iter; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (matchingNode) 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (path[compLen] == 0) 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return matchingNode; // Last element in path, return matching node. 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (matchingNode->getNodeType() == TESTNODETYPE_GROUP) 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return static_cast<const TestGroup*>(matchingNode)->findChildNode(path + compLen + 1); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return DE_NULL; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestRoot 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestRoot::TestRoot (void) 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestGroup(DE_NULL, TESTNODETYPE_ROOT, "", "") 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestCase 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase* TestCase::createAsChild(TestGroup* parent, TestCaseType caseType, const char *name, const char *description) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return new TestCase(parent, caseType, name, description); 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::TestCase (TestGroup* parent, TestCaseType caseType, const char* name, const char* description) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestNode (parent, TESTNODETYPE_TEST_CASE, name, description) 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseType (caseType) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::~TestCase (void) 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestHierarchyBuilder helpers 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid addChildGroupsToMap (std::map<std::string, TestGroup*>& groupMap, TestGroup* group) 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < group->getNumChildren(); ndx++) 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestNode* node = group->getChild(ndx); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (node->getNodeType() == TESTNODETYPE_GROUP) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestGroup* childGroup = static_cast<TestGroup*>(node); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string fullPath; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry childGroup->getFullPath(fullPath); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry groupMap.insert(std::make_pair(fullPath, childGroup)); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChildGroupsToMap(groupMap, childGroup); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestHierarchyBuilder 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestHierarchyBuilder::TestHierarchyBuilder (TestRoot* root) 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_root(root) 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChildGroupsToMap(m_groupMap, root); 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestHierarchyBuilder::~TestHierarchyBuilder (void) 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase* TestHierarchyBuilder::createCase (const char* path, TestCaseType caseType) 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2012-09-05 pyry] This can be done with less string manipulations. 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::string> components; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry splitPath(path, components); 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!components.empty()); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create all parents if necessary. 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestGroup* curGroup = m_root; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string curGroupPath; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)components.size()-1; ndx++) 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!curGroupPath.empty()) 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curGroupPath += "."; 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curGroupPath += components[ndx]; 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::map<std::string, TestGroup*>::const_iterator groupPos = m_groupMap.find(curGroupPath); 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (groupPos == m_groupMap.end()) 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestGroup* newGroup = curGroup->createGroup(components[ndx].c_str(), "" /* description */); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_groupMap.insert(std::make_pair(curGroupPath, newGroup)); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curGroup = newGroup; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry curGroup = groupPos->second; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return curGroup->createCase(caseType, components.back().c_str(), "" /* description */); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestSet helpers 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void addNodeAndParents (std::set<const TestNode*>& nodeSet, const TestNode* node) 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (node != DE_NULL) 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nodeSet.insert(node); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry node = node->getParent(); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void addChildren (std::set<const TestNode*>& nodeSet, const TestGroup* group) 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < group->getNumChildren(); ndx++) 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestNode* child = group->getChild(ndx); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nodeSet.insert(child); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (child->getNodeType() == TESTNODETYPE_GROUP) 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChildren(nodeSet, static_cast<const TestGroup*>(child)); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void removeChildren (std::set<const TestNode*>& nodeSet, const TestGroup* group) 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < group->getNumChildren(); ndx++) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestNode* child = group->getChild(ndx); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nodeSet.erase(child); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (child->getNodeType() == TESTNODETYPE_GROUP) 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeChildren(nodeSet, static_cast<const TestGroup*>(child)); 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool hasChildrenInSet (const std::set<const TestNode*>& nodeSet, const TestGroup* group) 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < group->getNumChildren(); ndx++) 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (nodeSet.find(group->getChild(ndx)) != nodeSet.end()) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void removeEmptyGroups (std::set<const TestNode*>& nodeSet, const TestGroup* group) 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!hasChildrenInSet(nodeSet, group)) 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry nodeSet.erase(group); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (group->getParent() != DE_NULL) 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeEmptyGroups(nodeSet, group->getParent()); 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// TestSet 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::add (const TestNode* node) 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (node->getNodeType() == TESTNODETYPE_TEST_CASE) 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addCase(static_cast<const TestCase*>(node)); 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry XE_CHECK(node->getNodeType() == TESTNODETYPE_GROUP || 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry node->getNodeType() == TESTNODETYPE_ROOT); 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addGroup(static_cast<const TestGroup*>(node)); 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::addCase (const TestCase* testCase) 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addNodeAndParents(m_set, testCase); 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::addGroup (const TestGroup* testGroup) 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addNodeAndParents(m_set, testGroup); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChildren(m_set, testGroup); 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::remove (const TestNode* node) 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (node->getNodeType() == TESTNODETYPE_TEST_CASE) 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeCase(static_cast<const TestCase*>(node)); 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry XE_CHECK(node->getNodeType() == TESTNODETYPE_GROUP || 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry node->getNodeType() == TESTNODETYPE_ROOT); 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeGroup(static_cast<const TestGroup*>(node)); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::removeCase (const TestCase* testCase) 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_set.find(testCase) != m_set.end()) 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_set.erase(testCase); 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeEmptyGroups(m_set, testCase->getParent()); 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TestSet::removeGroup (const TestGroup* testGroup) 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_set.find(testGroup) != m_set.end()) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_set.erase(testGroup); 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeChildren(m_set, testGroup); 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (testGroup->getParent() != DE_NULL) 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry removeEmptyGroups(m_set, testGroup->getParent()); 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ConstTestNodeIterator 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4313c827367444ee418f129b2c238299f49d3264554Jarkko PoyryConstTestNodeIterator::ConstTestNodeIterator (const TestNode* root) 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : m_root(root) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryConstTestNodeIterator ConstTestNodeIterator::begin (const TestNode* root) 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstTestNodeIterator iter(root); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry iter.m_iterStack.push_back(GroupState(DE_NULL)); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return iter; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko PoyryConstTestNodeIterator ConstTestNodeIterator::end (const TestNode* root) 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(root); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ConstTestNodeIterator(root); 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryConstTestNodeIterator& ConstTestNodeIterator::operator++ (void) 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_iterStack.empty()); 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestNode* curNode = **this; 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestNodeType curNodeType = curNode->getNodeType(); 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((curNodeType == TESTNODETYPE_GROUP || curNodeType == TESTNODETYPE_ROOT) && 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static_cast<const TestGroup*>(curNode)->getNumChildren() > 0) 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterStack.push_back(GroupState(static_cast<const TestGroup*>(curNode))); 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (;;) 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestGroup* group = m_iterStack.back().group; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int& childNdx = m_iterStack.back().childNdx; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numChildren = group ? group->getNumChildren() : 1; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry childNdx += 1; 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (childNdx == numChildren) 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterStack.pop_back(); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_iterStack.empty()) 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return *this; 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4843c827367444ee418f129b2c238299f49d3264554Jarkko PoyryConstTestNodeIterator ConstTestNodeIterator::operator++ (int) 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ConstTestNodeIterator copy(*this); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++(*this); 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return copy; 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst TestNode* ConstTestNodeIterator::operator* (void) const 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_iterStack.empty()); 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_iterStack.size() == 1) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_iterStack[0].group == DE_NULL && m_iterStack[0].childNdx == 0); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_root; 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_iterStack.back().group->getChild(m_iterStack.back().childNdx); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ConstTestNodeIterator::operator!= (const ConstTestNodeIterator& other) const 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return m_root != other.m_root || m_iterStack != other.m_iterStack; 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // xe 509