Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit caa8f1c2 authored by Hossain Mahmud's avatar Hossain Mahmud Committed by Christian Schulte zu Berge
Browse files

added the documentation (brief). added test class for StringUtils. trimmed out...

added the documentation (brief). added test class for StringUtils. trimmed out the redundant code segments.
parent aa8e9801
...@@ -64,17 +64,17 @@ namespace campvis { ...@@ -64,17 +64,17 @@ namespace campvis {
* *
* \param str Input string to parse. * \param str Input string to parse.
* *
* \note TODO: The detection algorithm is a litte simplified and will not yield correct results * \note TODO: The detection algorithm is a little simplified and will not yield correct results
* in every case. * in every case.
**/ **/
static std::vector<std::string> parseFloats(const std::string& str); static std::vector<std::string> parseFloats(const std::string& str);
/** /**
* Replaces all occurences of \a from in \a str with \a to. * Replaces all occurrences of \a from in \a str with \a to.
* \param str String to perform replacement on. * \param str String to perform replacement on.
* \param from String to be replaced. * \param from String to be replaced.
* \param to String repace. * \param to String replace.
* \return \a str with all occurences of \a from replaced with \a to. * \return \a str with all occurrences of \a from replaced with \a to.
*/ */
static std::string replaceAll(const std::string& str, const std::string& from, const std::string& to); static std::string replaceAll(const std::string& str, const std::string& from, const std::string& to);
...@@ -101,7 +101,7 @@ namespace campvis { ...@@ -101,7 +101,7 @@ namespace campvis {
/** /**
* Trims the string \a str. * Trims the string \a str.
* All leading and trailing occurences of the characters in \a whitespace will be removed. * All leading and trailing occurrences of the characters in \a whitespace will be removed.
* *
* \param str The string to trim. * \param str The string to trim.
* \param whitespace Set of whitespace characters which shall be removed at the beginning and the end. * \param whitespace Set of whitespace characters which shall be removed at the beginning and the end.
......
...@@ -14,7 +14,7 @@ FILE(GLOB TestCampvisSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ...@@ -14,7 +14,7 @@ FILE(GLOB TestCampvisSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.cpp *.cpp
core/datastructures/*.cpp core/datastructures/*.cpp
core/properties/*.cpp core/properties/*.cpp
#classification/*.cpp core/tools/*.cpp
#eventhandlers/*.cpp #eventhandlers/*.cpp
#pipeline/*.cpp #pipeline/*.cpp
) )
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
/**
* Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014
*/
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/datacontainer.h" #include "core/datastructures/datacontainer.h"
...@@ -7,6 +36,9 @@ ...@@ -7,6 +36,9 @@
using namespace campvis; using namespace campvis;
/**
* Test class for DataContainer class
*/
class DataContainerTest : public ::testing::Test { class DataContainerTest : public ::testing::Test {
protected: protected:
DataContainerTest() { DataContainerTest() {
...@@ -29,42 +61,36 @@ protected: ...@@ -29,42 +61,36 @@ protected:
AbstractData * _data; AbstractData * _data;
}; };
TEST_F(DataContainerTest, addDataTest) { /**
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); * Tests the trivial operations of the class.
this->_dc0->addData("data1", this->_data); * getName()
EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData()); * addData()
} * addDataHandle()
* getData()
TEST_F(DataContainerTest, getDataTest) { * hasData()
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); * removeData()
this->_dc0->addData("data1", this->_data); */
EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData()); TEST_F(DataContainerTest, miscellaneousTest) {
} EXPECT_EQ("dc0", this->_dc0->getName());
TEST_F(DataContainerTest, removeDataTest) {
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData());
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData()); EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData());
this->_dc0->addDataHandle("data2", DataHandle(this->_data));
this->_dc0->removeData("data1"); this->_dc0->removeData("data1");
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData()); EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData());
} // TODO: if the addDataHandle is called here instead of above
// this->_dc0->addDataHandle("data2", DataHandle(this->_data));
// the program crashes. Find why!!
TEST_F(DataContainerTest, addDataHandleTest) {
EXPECT_EQ(nullptr, this->_dc0->getData("data1").getData());
this->_dc0->addDataHandle("data1", DataHandle(this->_data));
EXPECT_EQ(this->_data, this->_dc0->getData("data1").getData());
}
TEST_F(DataContainerTest, hasDataTest) {
EXPECT_EQ(false, this->_dc0->hasData("data1"));
this->_dc0->addDataHandle("data1", DataHandle(this->_data));
EXPECT_EQ(true, this->_dc0->hasData("data1"));
this->_dc0->removeData("data1");
EXPECT_EQ(false, this->_dc0->hasData("data1")); EXPECT_EQ(false, this->_dc0->hasData("data1"));
EXPECT_EQ(true, this->_dc0->hasData("data2"));
} }
/**
* Tests the function getDataHandlesCopy.
*/
TEST_F(DataContainerTest, getDataHandlesCopyTest) { TEST_F(DataContainerTest, getDataHandlesCopyTest) {
EXPECT_EQ(0, this->_dc0->getDataHandlesCopy().size()); EXPECT_EQ(0, this->_dc0->getDataHandlesCopy().size());
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
...@@ -74,10 +100,12 @@ TEST_F(DataContainerTest, getDataHandlesCopyTest) { ...@@ -74,10 +100,12 @@ TEST_F(DataContainerTest, getDataHandlesCopyTest) {
EXPECT_EQ(this->_data, pair.second.getData()); EXPECT_EQ(this->_data, pair.second.getData());
} }
TEST_F(DataContainerTest, getNameTest) { /**
EXPECT_EQ("dc0", this->_dc0->getName()); * Tests the concurrent access settings of the class.
} *
* DataHandle of previously added data obtained with getData() should remains valid
* even if the data in the container is replaced with new data.
*/
TEST_F(DataContainerTest, concurrentAccessTest) { TEST_F(DataContainerTest, concurrentAccessTest) {
this->_dc0->addData("data1", this->_data); this->_dc0->addData("data1", this->_data);
DataHandle dh = this->_dc0->getData("data1"); DataHandle dh = this->_dc0->getData("data1");
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
/**
* Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014
*/
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/datahandle.h" #include "core/datastructures/datahandle.h"
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
/**
* Test class for DataHandle class. This class along with ImageDataTest and
* ImageSeriesTest completes the overall test environments for DataHandle and
* AbstractData.
*/
class DataHandleTest : public testing::Test { class DataHandleTest : public testing::Test {
protected: protected:
DataHandleTest() { DataHandleTest() {
...@@ -17,11 +50,9 @@ protected: ...@@ -17,11 +50,9 @@ protected:
} }
~DataHandleTest() { ~DataHandleTest() {
//delete _data1; //delete _data1; // DON'T mess with data added to the DataHandle. More at DataHanlde.h
} }
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following two methods
virtual void SetUp() { virtual void SetUp() {
} }
......
// include gtest library // ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
/**
* Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014
*/
#include "gtest/gtest.h" #include "gtest/gtest.h"
// include(s) for class to be tested
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
// additional dependency includes
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
/**
* Test class for ImageData class.
*/
class ImageDataTest : public testing::Test { class ImageDataTest : public testing::Test {
protected: protected:
ImageDataTest() { ImageDataTest() {
...@@ -36,15 +64,45 @@ protected: ...@@ -36,15 +64,45 @@ protected:
}; };
TEST_F(ImageDataTest, initTest) { /**
* Tests the trivial operations of the class.
* initialization
* getDimensionality()
* getNumChannels()
* getNumElements()
* getWorldBounds()
* get/setMappingInformation()
* positionToIndex()/indexToPosition()
*/
TEST_F(ImageDataTest, miscellaneousTest) {
ASSERT_TRUE(nullptr != _imgData1); ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(2, _imgData0->getDimensionality()); EXPECT_EQ(2, _imgData0->getDimensionality());
EXPECT_EQ(4, _imgData0->getNumChannels()); EXPECT_EQ(4, _imgData0->getNumChannels());
EXPECT_EQ(tgt::hmul(tgt::svec3(1,2,3)), _imgData0->getNumElements()); EXPECT_EQ(tgt::hmul(tgt::svec3(1,2,3)), _imgData0->getNumElements());
EXPECT_EQ(tgt::svec3(1,2,3).size, _imgData0->getSize().size); EXPECT_EQ(tgt::svec3(1,2,3).size, _imgData0->getSize().size);
tgt::Bounds bound0 = _imgData0->getWorldBounds();
tgt::Bounds bound1 = _imgData1->getWorldBounds();
EXPECT_EQ(bound0, bound1);
campvis::ImageData temp = campvis::ImageData(3, tgt::svec3(3,2,1), 5);
temp.setMappingInformation(_imgData0->getMappingInformation());
EXPECT_TRUE(temp.getMappingInformation() == _imgData0->getMappingInformation());
tgt::svec3 vec(1, 2, 3);
_imgData0->positionToIndex(vec);
EXPECT_EQ(1, 1);
size_t sz = 3;
_imgData0->indexToPosition(sz);
EXPECT_EQ(1, 1);
} }
/**
* Tests the clone() function.
*/
TEST_F(ImageDataTest, cloneTest) { TEST_F(ImageDataTest, cloneTest) {
ASSERT_TRUE(nullptr != _imgData1); ASSERT_TRUE(nullptr != _imgData1);
...@@ -59,19 +117,11 @@ TEST_F(ImageDataTest, cloneTest) { ...@@ -59,19 +117,11 @@ TEST_F(ImageDataTest, cloneTest) {
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint()); EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint());
} }
TEST_F(ImageDataTest, getSetMappingInformationTest) { /**
campvis::ImageData temp = campvis::ImageData(3, tgt::svec3(3,2,1), 5); * Tests getSubImage() method.
temp.setMappingInformation(_imgData0->getMappingInformation()); *
* For test cases 1. whole image and 2. images of size (1,1,1) were checked
EXPECT_TRUE(temp.getMappingInformation() == _imgData0->getMappingInformation()); */
}
TEST_F(ImageDataTest, getWorldBoundsTest) {
tgt::Bounds bound0 = _imgData0->getWorldBounds();
tgt::Bounds bound1 = _imgData1->getWorldBounds();
EXPECT_EQ(bound0, bound1);
}
TEST_F(ImageDataTest, getSubImageTest) { TEST_F(ImageDataTest, getSubImageTest) {
campvis::ImageData *cloned = _imgData0->getSubImage(tgt::svec3(0,0,0), _imgData0->getSize()); campvis::ImageData *cloned = _imgData0->getSubImage(tgt::svec3(0,0,0), _imgData0->getSize());
...@@ -92,15 +142,3 @@ TEST_F(ImageDataTest, getSubImageTest) { ...@@ -92,15 +142,3 @@ TEST_F(ImageDataTest, getSubImageTest) {
cloned = _imgData0->getSubImage(_imgData0->getSize()-tgt::svec3(1,1,1), _imgData0->getSize()); cloned = _imgData0->getSubImage(_imgData0->getSize()-tgt::svec3(1,1,1), _imgData0->getSize());
EXPECT_EQ(tgt::svec3(1,1,1), cloned->getSize()); EXPECT_EQ(tgt::svec3(1,1,1), cloned->getSize());
} }
TEST_F(ImageDataTest, positionToIndexTest) {
tgt::svec3 vec(1, 2, 3);
size_t sz = _imgData0->positionToIndex(vec);
EXPECT_EQ(1, 1);
}
TEST_F(ImageDataTest, indexToPositionTest) {
size_t sz = 3;
tgt::svec3 vec = _imgData0->indexToPosition(sz);
EXPECT_EQ(1, 1);
}
// include gtest library // ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
/**
* Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014
*/
#include "gtest/gtest.h" #include "gtest/gtest.h"
// include(s) for class to be tested
#include "core/datastructures/imageseries.h" #include "core/datastructures/imageseries.h"
// additional includes
#include "core/datastructures/imagedata.h" #include "core/datastructures/imagedata.h"
/**
* Test class for ImageSeries class.
*/
class ImageSeriesTest : public testing::Test { class ImageSeriesTest : public testing::Test {
protected: protected:
ImageSeriesTest() { ImageSeriesTest() {
...@@ -18,12 +46,10 @@ protected: ...@@ -18,12 +46,10 @@ protected:
_imgSeries3.addImage(_dh); _imgSeries3.addImage(_dh);
} }
~ImageSeriesTest() { ~ImageSeriesTest() {
//delete _image; //delete _image; // Don't even think about it. Check DataHandle.h
} }
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following two methods
virtual void SetUp() { virtual void SetUp() {
} }
...@@ -38,29 +64,28 @@ protected: ...@@ -38,29 +64,28 @@ protected:
}; };
TEST_F(ImageSeriesTest, getNumImageTest) { /**
* Tests trivial functions of the class
*
* addImage()
* getNumImages()
* getImage()
*/
TEST_F(ImageSeriesTest, miscellaneousTest) {
EXPECT_EQ(0, _imgSeries1.getNumImages()); EXPECT_EQ(0, _imgSeries1.getNumImages());
EXPECT_EQ(1, _imgSeries2.getNumImages()); EXPECT_EQ(1, _imgSeries2.getNumImages());
EXPECT_EQ(1, _imgSeries3.getNumImages()); EXPECT_EQ(1, _imgSeries3.getNumImages());
}
TEST_F(ImageSeriesTest, addImageTest) {
_imgSeries3.addImage(_image); _imgSeries3.addImage(_image);
EXPECT_EQ(2, _imgSeries3.getNumImages()); EXPECT_EQ(2, _imgSeries3.getNumImages());
}
TEST_F(ImageSeriesTest, getImageTest) {
EXPECT_EQ(_dh.getData(), _imgSeries3.getImage(_imgSeries3.getNumImages()-1).getData()); EXPECT_EQ(_dh.getData(), _imgSeries3.getImage(_imgSeries3.getNumImages()-1).getData());
} }
TEST_F(ImageSeriesTest, getLocalMemoryFootprintTest) {
SUCCEED();
}
TEST_F(ImageSeriesTest, getVideoMemoryFootprintTest) {
SUCCEED();
}
/**
* Tests the method clone()
*/
TEST_F(ImageSeriesTest, cloneTest) { TEST_F(ImageSeriesTest, cloneTest) {
campvis::ImageSeries* tempSeries = _imgSeries2.clone(); campvis::ImageSeries* tempSeries = _imgSeries2.clone();
EXPECT_EQ(_imgSeries2.getNumImages(), tempSeries->getNumImages()); EXPECT_EQ(_imgSeries2.getNumImages(), tempSeries->getNumImages());
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
/**
* Author: Hossain Mahmud <mahmud@in.tum.de>
* Date: March 2014
*/
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "core/datastructures/renderdata.h" #include "core/datastructures/renderdata.h"
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0