1 // ----------------------------------------------------------------------------
2 // -                        Open3D: www.open3d.org                            -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #include "UnitTest.h"
28 
29 #include "Core/Geometry/Image.h"
30 
TEST(Image,Default)31 TEST(Image, Default)
32 {
33     NotImplemented();
34 }
35 
TEST(Image,DefaultConstructor)36 TEST(Image, DefaultConstructor)
37 {
38     three::Image image;
39 
40     // inherited from Geometry2D
41     EXPECT_EQ(three::Geometry::GeometryType::Image, image.GetGeometryType());
42     EXPECT_EQ(2, image.Dimension());
43 
44     // public member variables
45     EXPECT_EQ(0, image.width_);
46     EXPECT_EQ(0, image.height_);
47     EXPECT_EQ(0, image.num_of_channels_);
48     EXPECT_EQ(0, image.bytes_per_channel_);
49     EXPECT_EQ(0, image.data_.size());
50 
51     // public members
52     EXPECT_TRUE(image.IsEmpty());
53     EXPECT_EQ(Eigen::Vector2d(0.0, 0.0), image.GetMinBound());
54     EXPECT_EQ(Eigen::Vector2d(0.0, 0.0), image.GetMaxBound());
55 
56     image.Clear();
57 
58     // public member variables
59     EXPECT_EQ(0, image.width_);
60     EXPECT_EQ(0, image.height_);
61     EXPECT_EQ(0, image.num_of_channels_);
62     EXPECT_EQ(0, image.bytes_per_channel_);
63     EXPECT_EQ(0, image.data_.size());
64 
65     // public members
66     EXPECT_TRUE(image.IsEmpty());
67     EXPECT_EQ(Eigen::Vector2d(0.0, 0.0), image.GetMinBound());
68     EXPECT_EQ(Eigen::Vector2d(0.0, 0.0), image.GetMaxBound());
69 
70     image.width_ = 1920;
71     image.height_ = 1080;
72     image.num_of_channels_ = 3;
73     image.bytes_per_channel_ = 8;
74 
75     // public member variables
76     EXPECT_EQ(1920, image.width_);
77     EXPECT_EQ(1080, image.height_);
78     EXPECT_EQ(3, image.num_of_channels_);
79     EXPECT_EQ(8, image.bytes_per_channel_);
80     EXPECT_EQ(0, image.data_.size());
81 
82     // public members
83     EXPECT_TRUE(image.IsEmpty());
84     EXPECT_EQ(Eigen::Vector2d(0.0, 0.0), image.GetMinBound());
85     EXPECT_EQ(Eigen::Vector2d(1920, 1080), image.GetMaxBound());
86 }
87