@@ -33,7 +33,7 @@ bool UnitTestReadTree::run() {
3333 // TODO will be chnaged this to keeped files on the disk
3434 CompStruct comp;
3535
36- std::string sFilename = " ./data/readtreetest/example1.obj-tree" ;
36+ std::string sFilename = " ./data/readtreetest/example1.wsjcpp- obj-tree" ;
3737 std::string sError ;
3838 bool bWrote = comp.readTreeFromFile (sFilename , sError );
3939 compareB (bTestSuccess, " read from file" , bWrote, true );
@@ -42,13 +42,26 @@ bool UnitTestReadTree::run() {
4242 }
4343
4444 WsjcppLog::info (TAG, " \n " + comp.toString ());
45-
46- // char *pBuffer = nullptr;
47- // int nBufferSize = 0;
48- // WsjcppCore::readFileToBuffer(sFilename, &pBuffer, nBufferSize);
45+ compareN (bTestSuccess, " user version " , comp.getUserVersionOfTree (), 1 );
46+
47+ std::vector<WsjcppObjTreeNodeString *> vFoundNodes;
48+
49+ comp.findNodes (" PCI_EXPRESS" , vFoundNodes);
50+
51+ compareN (bTestSuccess, " find PCI_EXPRESS" , vFoundNodes.size (), 1 );
52+ if (vFoundNodes.size () == 1 ) {
53+ WsjcppObjTreeNodeString *pNode = vFoundNodes[0 ];
54+ compareN (bTestSuccess, " node id" , pNode->getId (), 13 );
55+ compareN (bTestSuccess, " find PCI_EXPRESS" , pNode->getChilds ().size (), 1 );
56+ if (pNode->getChilds ().size () == 1 ) {
57+ WsjcppObjTreeNode *pNodeChild_ = pNode->getChilds ()[0 ];
58+ compareN (bTestSuccess, " child node type" , pNodeChild_->getType (), WSJCPP_OBJ_TREE_NODE_INTEGER);
59+ compareN (bTestSuccess, " child node id" , pNodeChild_->getId (), 14 );
60+ compareN (bTestSuccess, " child node parent id (1)" , pNode->getId (), pNodeChild_->getParent ()->getId ());
61+ compareN (bTestSuccess, " child node parent id (2)" , pNodeChild_->getParent ()->getId (), 13 );
62+ }
63+ }
4964
50- // compareN(bTestSuccess, "read to file", nBufferSize, 296);
51-
5265 return bTestSuccess;
5366}
5467
0 commit comments