Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

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

TESTs code for core/datastructures/imagedata, core/datastructures/datahandle

parent 6f9d4563
......@@ -79,4 +79,14 @@ namespace campvis {
return _worldToVoxelTransformation;
}
bool ImageMappingInformation::operator==(const ImageMappingInformation& obj) const{
return (this->_offset == obj._offset)
&& (this->_size == obj._size)
&& (this->_voxelSize == obj._voxelSize)
//&& (this->_realWorldValueMapping == obj._realWorldValueMapping)
&& (this->_textureToWorldTransformation == obj._textureToWorldTransformation)
&& (this->_voxelToWorldTransformation == obj._voxelToWorldTransformation)
&& (this->_worldToTextureTransformation == obj._worldToTextureTransformation)
&& (this->_worldToVoxelTransformation == obj._worldToVoxelTransformation);
}
}
......@@ -95,13 +95,19 @@ namespace campvis {
* \return Linear mapping for mapping element values to real world values.
*/
const LinearMapping<float>& getRealWorldMapping() const;
/**
* Set the real world value mapping.
* \param rwvm Linear mapping for mapping element values to real world values.
*/
void setRealWorldMapping(const LinearMapping<float>& rwvm);
/**
* Overloaded equal operator
* \param obj Object to compare with.
*/
bool operator==(const ImageMappingInformation& obj) const ;
private:
/**
* Updates the X-to-Y matrices.
......
......@@ -38,6 +38,7 @@ GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from gtest_main.cc\n");
testing::InitGoogleTest(&argc, argv);
int ret= RUN_ALL_TESTS();
getchar();
return ret;
printf("gtest_main.cc returned with %d\n", ret);
//getchar();
return 0;
}
// include gtest library
#include "gtest/gtest.h"
// include(s) for class to be tested
#include "core/datastructures/datahandle.h"
// additional dependency includes
#include "core/datastructures/imagedata.h"
class DataHandleTest : public testing::Test {
protected:
DataHandleTest() {
_data1 = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
_dh0 = new campvis::DataHandle();
_dh1 = new campvis::DataHandle(_data1);
_dh2 = new campvis::DataHandle(*_dh1);
_dh3 = *_dh2;
}
~DataHandleTest() {
// Note: Can't explicitely delete them, there's a note on the constructor
// tgt::Singleton<campvis::SimpleJobProcessor>>::getRef() assertions fails
// in the second delete!
//delete _dh1;
//delete _dh2;
delete _data1;
}
// 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 TearDown() {
}
protected:
campvis::DataHandle *_dh0, *_dh1, *_dh2, _dh3, _dh4;
campvis::AbstractData * _data1;
};
TEST_F(DataHandleTest, getDataTest) {
ASSERT_TRUE(nullptr == _dh0->getData());
EXPECT_EQ(_dh1->getData(), _dh2->getData());
EXPECT_EQ(_dh1->getData(), _dh3.getData());
EXPECT_EQ(nullptr, _dh4.getData());
}
TEST_F(DataHandleTest, getTimestampTest) {
EXPECT_NE(-1, _dh0->getTimestamp());
EXPECT_NE(-1, _dh1->getTimestamp());
EXPECT_NE(-1, _dh2->getTimestamp());
EXPECT_NE(-1, _dh3.getTimestamp());
EXPECT_NE(-1, _dh4.getTimestamp());
EXPECT_EQ(_dh1->getTimestamp(), _dh2->getTimestamp());
EXPECT_EQ(_dh1->getTimestamp(), _dh3.getTimestamp());
}
// include gtest library
#include "gtest/gtest.h"
// include(s) for class to be tested
#include "core/datastructures/imagedata.h"
// additional dependency includes
#include "core/datastructures/imagedata.h"
class ImageDataTest : public testing::Test {
protected:
ImageDataTest() {
_imgData0 = new campvis::ImageData(2, tgt::svec3(1,2,3), 4);
_imgData1 = _imgData0->clone();
_absData1 = _imgData1;
}
~ImageDataTest() {
delete _imgData0;
delete _imgData1;
}
// 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 TearDown() {
}
protected:
campvis::ImageData *_imgData0, *_imgData1;//, *_imgData2, _imgData3, _imgData4;
campvis::AbstractData * _absData1;
};
TEST_F(ImageDataTest, initTest) {
ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(2, _imgData0->getDimensionality());
EXPECT_EQ(4, _imgData0->getNumChannels());
EXPECT_EQ(tgt::hmul(tgt::svec3(1,2,3)), _imgData0->getNumElements());
EXPECT_EQ(tgt::svec3(1,2,3).size, _imgData0->getSize().size);
}
TEST_F(ImageDataTest, cloneTest) {
ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(_imgData0->getDimensionality(), _imgData1->getDimensionality());
EXPECT_EQ(_imgData0->getLocalMemoryFootprint(), _imgData1->getLocalMemoryFootprint());
EXPECT_TRUE(_imgData0->getMappingInformation() == _imgData1->getMappingInformation());
EXPECT_EQ(_imgData0->getNumChannels(), _imgData1->getNumChannels());
EXPECT_EQ(_imgData0->getNumElements(), _imgData1->getNumElements());
//EXPECT_EQ(_imgData0->getRepresentation(), _imgData1->getRepresentation());
EXPECT_EQ(_imgData0->getSize(), _imgData1->getSize());
//EXPECT_EQ(_imgData0->getSubImage(), _imgData1->getSubImage());
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), _imgData1->getVideoMemoryFootprint());
}
TEST_F(ImageDataTest, getSetMappingInformationTest) {
campvis::ImageData temp = campvis::ImageData(3, tgt::svec3(3,2,1), 5);
temp.setMappingInformation(_imgData0->getMappingInformation());
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) {
campvis::ImageData *cloned = _imgData0->getSubImage(tgt::svec3(0,0,0), _imgData0->getSize());
ASSERT_TRUE(nullptr != _imgData1);
EXPECT_EQ(_imgData0->getDimensionality(), cloned->getDimensionality());
EXPECT_EQ(_imgData0->getLocalMemoryFootprint(), cloned->getLocalMemoryFootprint());
EXPECT_TRUE(_imgData0->getMappingInformation() == cloned->getMappingInformation());
EXPECT_EQ(_imgData0->getNumChannels(), cloned->getNumChannels());
EXPECT_EQ(_imgData0->getNumElements(), cloned->getNumElements());
//EXPECT_EQ(_imgData0->getRepresentation(), cloned->getRepresentation());
EXPECT_EQ(_imgData0->getSize(), cloned->getSize());
//EXPECT_EQ(_imgData0->getSubImage(), cloned->getSubImage());
EXPECT_EQ(_imgData0->getVideoMemoryFootprint(), cloned->getVideoMemoryFootprint());
delete cloned;
cloned = _imgData0->getSubImage(_imgData0->getSize()-tgt::svec3(1,1,1), _imgData0->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/gtest.h"
//#include "someclass.h"
//#include "modules/io/processors/abstractimagereader.h"
//#include "modules/io/processors/mhdimagereader.h"
//#include "core/properties/genericproperty.h"
TEST(a, b) {
ASSERT_EQ(1,1);
class SomeClassTest : public ::testing::Test {
protected:
SomeClassTest() {
}
~SomeClassTest() {
}
// 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 TearDown() {
}
private:
};
TEST_F(SomeClassTest, assertTrue) {
ASSERT_EQ(1, 1);
}
TEST(a, c) {
ASSERT_EQ(1,0);
TEST_F(SomeClassTest, assertFalse) {
ASSERT_NE(1, 0);
}
//TEST(ImageReaderTest, MhdImageReaderTest) {
// campvis::MhdImageReader *ir = new campvis::MhdImageReader();
// ir->setURL(campvis::StringProperty("url","sometitle", "someurl"));
// EXPECT_STRCASEEQ("someurl", ir->p_url.getValue().c_str());
//}
\ No newline at end of file
#include "gtest/gtest.h"
#include "modules/io/processors/abstractimagereader.h"
#include "modules/io/processors/mhdimagereader.h"
#include "core/properties/genericproperty.h"
TEST(ImageReaderTest, MhdImageReaderTest) {
campvis::MhdImageReader *ir = new campvis::MhdImageReader();
ir->setURL(campvis::StringProperty("url","sometitle", "someurl"));
EXPECT_STRCASEEQ("someurl", ir->p_url.getValue().c_str());
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment