From 47fe3421585302f2101691a685ab99b0e1ad5cfc Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 1 May 2015 17:48:32 +0200 Subject: Change XMLNode* to XMLNode An XMLNode object is already simply a pointer, so no need to dynamically allocate XMLNodes. --- tests/test_XMLDocument.cpp | 52 ++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'tests') diff --git a/tests/test_XMLDocument.cpp b/tests/test_XMLDocument.cpp index adabdd6..07abee3 100644 --- a/tests/test_XMLDocument.cpp +++ b/tests/test_XMLDocument.cpp @@ -38,12 +38,12 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_Constructor1 ) astra::XMLDocument *doc = astra::XMLDocument::createDocument("test"); BOOST_REQUIRE(doc); - astra::XMLNode *root = doc->getRootNode(); + astra::XMLNode root = doc->getRootNode(); BOOST_REQUIRE(root); - BOOST_CHECK(root->getName() == "test"); - BOOST_CHECK(root->getContent().empty()); + BOOST_CHECK(root.getName() == "test"); + BOOST_CHECK(root.getContent().empty()); } BOOST_AUTO_TEST_CASE( testXMLDocument_FileIO ) @@ -53,12 +53,12 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_FileIO ) doc->saveToFile("test.xml"); astra::XMLDocument *doc2 = astra::XMLDocument::readFromFile("test.xml"); - astra::XMLNode *root = doc2->getRootNode(); + astra::XMLNode root = doc2->getRootNode(); BOOST_REQUIRE(root); - BOOST_CHECK(root->getName() == "test"); - BOOST_CHECK(root->getContent().empty()); + BOOST_CHECK(root.getName() == "test"); + BOOST_CHECK(root.getContent().empty()); } @@ -67,32 +67,28 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_CreateNodes ) astra::XMLDocument *doc = astra::XMLDocument::createDocument("test"); BOOST_REQUIRE(doc); - astra::XMLNode *root = doc->getRootNode(); + astra::XMLNode root = doc->getRootNode(); BOOST_REQUIRE(root); - astra::XMLNode *node = root->addChildNode("child"); + astra::XMLNode node = root.addChildNode("child"); BOOST_REQUIRE(node); - node->addAttribute("attr", "val"); + node.addAttribute("attr", "val"); doc->saveToFile("test2.xml"); - delete node; - delete root; delete doc; doc = astra::XMLDocument::readFromFile("test2.xml"); BOOST_REQUIRE(doc); root = doc->getRootNode(); BOOST_REQUIRE(node); - node = root->getSingleNode("child"); + node = root.getSingleNode("child"); BOOST_REQUIRE(node); - BOOST_CHECK(node->hasAttribute("attr")); - BOOST_CHECK(node->getAttribute("attr") == "val"); + BOOST_CHECK(node.hasAttribute("attr")); + BOOST_CHECK(node.getAttribute("attr") == "val"); - delete node; - delete root; delete doc; } @@ -101,16 +97,16 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_Options ) astra::XMLDocument *doc = astra::XMLDocument::createDocument("test"); BOOST_REQUIRE(doc); - astra::XMLNode *root = doc->getRootNode(); + astra::XMLNode root = doc->getRootNode(); BOOST_REQUIRE(root); - BOOST_CHECK(!root->hasOption("opt")); + BOOST_CHECK(!root.hasOption("opt")); - root->addOption("opt", "val"); + root.addOption("opt", "val"); - BOOST_CHECK(root->hasOption("opt")); + BOOST_CHECK(root.hasOption("opt")); - BOOST_CHECK(root->getOption("opt") == "val"); + BOOST_CHECK(root.getOption("opt") == "val"); } @@ -119,39 +115,35 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_List ) astra::XMLDocument *doc = astra::XMLDocument::createDocument("test"); BOOST_REQUIRE(doc); - astra::XMLNode *root = doc->getRootNode(); + astra::XMLNode root = doc->getRootNode(); BOOST_REQUIRE(root); - astra::XMLNode *node = root->addChildNode("child"); + astra::XMLNode node = root.addChildNode("child"); BOOST_REQUIRE(node); float fl[] = { 1.0, 3.5, 2.0, 4.75 }; - node->setContent(fl, sizeof(fl)/sizeof(fl[0])); + node.setContent(fl, sizeof(fl)/sizeof(fl[0])); doc->saveToFile("test3.xml"); - delete node; - delete root; delete doc; doc = astra::XMLDocument::readFromFile("test3.xml"); BOOST_REQUIRE(doc); root = doc->getRootNode(); BOOST_REQUIRE(root); - node = root->getSingleNode("child"); + node = root.getSingleNode("child"); BOOST_REQUIRE(node); - std::vector f = node->getContentNumericalArray(); + std::vector f = node.getContentNumericalArray(); BOOST_CHECK(f[0] == fl[0]); BOOST_CHECK(f[1] == fl[1]); BOOST_CHECK(f[2] == fl[2]); BOOST_CHECK(f[3] == fl[3]); - delete node; - delete root; delete doc; } -- cgit v1.2.3 From c6f6d6fbc3537cedefc0cef8e71819436a0a60c1 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 6 May 2015 10:27:22 +0200 Subject: Add extra XMLNode/XMLDocument/Config test --- tests/test_XMLDocument.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test_XMLDocument.cpp b/tests/test_XMLDocument.cpp index 07abee3..18e880d 100644 --- a/tests/test_XMLDocument.cpp +++ b/tests/test_XMLDocument.cpp @@ -32,6 +32,7 @@ $Id$ #include #include "astra/XMLDocument.h" +#include "astra/Config.h" BOOST_AUTO_TEST_CASE( testXMLDocument_Constructor1 ) { @@ -148,3 +149,18 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_List ) } +BOOST_AUTO_TEST_CASE( testXMLDocument_Config ) +{ + astra::Config* cfg = new astra::Config(); + cfg->initialize("VolumeGeometry2D"); + + cfg->self.addChildNode("GridColCount", 1); + cfg->self.addChildNode("GridRowCount", 2); + + cfg->self.addOption("WindowMinX", 3); + cfg->self.addOption("WindowMaxX", 4); + cfg->self.addOption("WindowMinY", 5); + cfg->self.addOption("WindowMaxY", 6); + + delete cfg; +} -- cgit v1.2.3 From 3f6079b9dc2e3b6f54f512f6eb9c47b913fcd1c7 Mon Sep 17 00:00:00 2001 From: joergkappes Date: Sat, 28 Mar 2015 18:09:40 +0100 Subject: fix to small memory allocation --- tests/test_Fourier.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_Fourier.cpp b/tests/test_Fourier.cpp index 2602edb..ef12747 100644 --- a/tests/test_Fourier.cpp +++ b/tests/test_Fourier.cpp @@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE( testFourier_FFT_1D_1 ) { astra::float32 inR[8] = { 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f }; astra::float32 inI[8] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - astra::float32 outR[5]; - astra::float32 outI[5]; + astra::float32 outR[8]; + astra::float32 outI[8]; astra::fastTwoPowerFourierTransform1D(8, inR, inI, outR, outI, 1, 1, false); -- cgit v1.2.3 From f4dcfd65f2695fd2163109e6577fb61c524c9d5f Mon Sep 17 00:00:00 2001 From: joergkappes Date: Sat, 28 Mar 2015 18:20:06 +0100 Subject: fix memleaks in test --- tests/test_ParallelBeamLineKernelProjector2D.cpp | 2 ++ tests/test_XMLDocument.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/test_ParallelBeamLineKernelProjector2D.cpp b/tests/test_ParallelBeamLineKernelProjector2D.cpp index 86bc54f..c56ff37 100644 --- a/tests/test_ParallelBeamLineKernelProjector2D.cpp +++ b/tests/test_ParallelBeamLineKernelProjector2D.cpp @@ -77,6 +77,8 @@ BOOST_FIXTURE_TEST_CASE( testParallelBeamLineKernelProjector2D_Rectangle, TestPa fWeight += pPix[i].m_fWeight; BOOST_CHECK_SMALL(fWeight - 7.13037f, 0.00001f); + + delete[] pPix; } diff --git a/tests/test_XMLDocument.cpp b/tests/test_XMLDocument.cpp index 18e880d..95429cb 100644 --- a/tests/test_XMLDocument.cpp +++ b/tests/test_XMLDocument.cpp @@ -45,6 +45,9 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_Constructor1 ) BOOST_CHECK(root.getName() == "test"); BOOST_CHECK(root.getContent().empty()); + + delete doc; + } BOOST_AUTO_TEST_CASE( testXMLDocument_FileIO ) @@ -61,6 +64,9 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_FileIO ) BOOST_CHECK(root.getName() == "test"); BOOST_CHECK(root.getContent().empty()); + delete doc2; + delete doc; + } BOOST_AUTO_TEST_CASE( testXMLDocument_CreateNodes ) @@ -109,6 +115,8 @@ BOOST_AUTO_TEST_CASE( testXMLDocument_Options ) BOOST_CHECK(root.getOption("opt") == "val"); + delete doc; + } BOOST_AUTO_TEST_CASE( testXMLDocument_List ) -- cgit v1.2.3