24 #include "cheetah/data/test/DataSequence2DTest.h" 25 #include "cheetah/data/DataSequence2D.h" 26 #include "cheetah/data/DataSequence2DFastIterator.h" 27 #include "cheetah/data/DataSequence2DPartialIterator.h" 37 DataSequence2DTest::DataSequence2DTest()
41 DataSequence2DTest::~DataSequence2DTest()
45 void DataSequence2DTest::SetUp(){}
46 void DataSequence2DTest::TearDown(){}
48 TEST_F(DataSequence2DTest, test_empty)
50 data::DataSequence2D<Cpu,uint8_t> empty;
51 ASSERT_EQ(empty.fast_axis_length(),0U);
52 ASSERT_EQ(empty.slow_axis_length(),0U);
55 TEST_F(DataSequence2DTest, test_create)
57 const std::size_t x=16;
58 const std::size_t y=4;
59 data::DataSequence2D<Cpu,uint8_t> ds2d(x,y);
60 ASSERT_EQ(x,ds2d.fast_axis_length());
61 ASSERT_EQ(y,ds2d.slow_axis_length());
64 TEST_F(DataSequence2DTest, test_fill)
66 const std::size_t x=16;
67 const std::size_t y=4;
68 data::DataSequence2D<Cpu,uint8_t> ds2d(x,y,144);
69 ASSERT_EQ(x,ds2d.fast_axis_length());
70 ASSERT_EQ(y,ds2d.slow_axis_length());
72 ASSERT_EQ(uint8_t(144),v);
77 TEST_F(DataSequence2DTest, test_copy)
79 const std::size_t x=16;
80 const std::size_t y=4;
81 data::DataSequence2D<Cpu,uint8_t> ds2d(x,y,138);
82 ASSERT_EQ(x,ds2d.fast_axis_length());
83 ASSERT_EQ(y,ds2d.slow_axis_length());
85 data::DataSequence2D<Cpu,uint8_t> ds2d_copy(x,y);
86 std::copy(ds2d.begin(), ds2d.end(), ds2d_copy.begin());
87 ASSERT_EQ(x,ds2d_copy.fast_axis_length());
88 ASSERT_EQ(y,ds2d_copy.slow_axis_length());
89 auto it = ds2d.begin();
90 auto it2 = ds2d_copy.begin();
91 while (it != ds2d.end()){
99 TEST_F(DataSequence2DTest, test_partialfill){
100 const std::size_t l=4;
101 data::DataSequence2D<Cpu,uint8_t> ds2d(l,l,0);
103 auto slice = ds2d.slice(1,3,0,2);
105 while (slice != slice.end()){
113 if(x >=1 && x < 3 && y >= 0 && y < 2)
127 TEST_F(DataSequence2DTest, test_copyfailure){
128 const std::size_t x=16;
129 const std::size_t y=4;
130 data::DataSequence2D<Cpu,uint8_t> ds2d(x,y,138);
131 ASSERT_EQ(x,ds2d.fast_axis_length());
132 ASSERT_EQ(y,ds2d.slow_axis_length());
134 data::DataSequence2D<Cpu,uint8_t> ds2d_copy;
135 ASSERT_EQ(0U,ds2d_copy.fast_axis_length());
136 ASSERT_EQ(0U,ds2d_copy.slow_axis_length());
137 ASSERT_DEATH(std::copy(ds2d.begin(), ds2d.end(), ds2d_copy.begin()),
"Cannot dereference*");
139 data::DataSequence2D<Cpu,uint8_t> ds2d_copy2(x,2);
140 ASSERT_DEATH(std::copy(ds2d.begin(), ds2d.end(), ds2d_copy2.begin()),
"Cannot dereference*");
145 TEST_F(DataSequence2DTest, test_badslicefailure){
146 const std::size_t l=4;
147 data::DataSequence2D<Cpu,uint8_t> ds2d(l,l,0);
149 ASSERT_DEATH(ds2d.slice(1,6,0,2),
"Assert");
Some limits and constants for FLDO.