Scroom  0.14
colormaphelpers_test.cc File Reference
#include <list>
#include <type_traits>
#include <utility>
#include <boost/assign/list_of.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/parameterized_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>
#include <scroom/colormappable.hh>
#include <scroom/unused.hh>
Include dependency graph for colormaphelpers_test.cc:

Classes

struct  anonymous_namespace{colormaphelpers_test.cc}::Data
 

Namespaces

 anonymous_namespace{colormaphelpers_test.cc}
 

Functions

std::ostream & anonymous_namespace{colormaphelpers_test.cc}::operator<< (std::ostream &os, const Data &)
 
 BOOST_REQUIRE (originalColormap)
 
 BOOST_CHECK_EQUAL (sample.expectedColors, originalColormap->colors.size())
 
 BOOST_REQUIRE (colormap)
 
 BOOST_CHECK_EQUAL (sample.expectedColors, colormap->colors.size())
 
 BOOST_CHECK_EQUAL (originalColormap, colormap)
 
 BOOST_AUTO_TEST_CASE (regular_colormaps_cant_have_their_colors_set)
 
 BOOST_AUTO_TEST_CASE (monochrome_colormap_can_have_its_color_set)
 
 BOOST_AUTO_TEST_CASE (inverted_monochrome_colormap_can_have_its_color_set)
 

Variables

const Color anonymous_namespace{colormaphelpers_test.cc}::Blue (0, 0, 1)
 
const double anonymous_namespace{colormaphelpers_test.cc}::accuracy = 1e-4
 
std::list< Data > anonymous_namespace{colormaphelpers_test.cc}::helpers
 
const Colormap::Ptr colormap = sample.helper->getColormap()
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( inverted_monochrome_colormap_can_have_its_color_set  )
90 {
92  Colormap::Ptr const originalOriginalColormap = helper->getOriginalColormap();
93 
94  // At least one color in the current colormap doesn't have a blue component
95  BOOST_CHECK_NE(1, helper->getColormap()->colors.back().blue);
96 
97  helper->setMonochromeColor(Blue);
98  BOOST_CHECK_EQUAL(originalOriginalColormap, helper->getOriginalColormap());
99 
100  Colormap::Ptr const newColorMap = helper->getColormap();
101  for(Color const& c: newColorMap->colors)
102  {
103  BOOST_CHECK_CLOSE(1, c.blue, accuracy);
104  }
105 
106  Color const currentColor = helper->getMonochromeColor();
107  BOOST_CHECK_CLOSE(Blue.red, currentColor.red, accuracy);
108  BOOST_CHECK_CLOSE(Blue.green, currentColor.green, accuracy);
109  BOOST_CHECK_CLOSE(Blue.blue, currentColor.blue, accuracy);
110 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( monochrome_colormap_can_have_its_color_set  )
67 {
69  Colormap::Ptr const originalOriginalColormap = helper->getOriginalColormap();
70 
71  // At least one color in the current colormap doesn't have a blue component
72  BOOST_CHECK_NE(1, helper->getColormap()->colors[0].blue);
73 
74  helper->setMonochromeColor(Blue);
75  BOOST_CHECK_EQUAL(originalOriginalColormap, helper->getOriginalColormap());
76 
77  Colormap::Ptr const newColorMap = helper->getColormap();
78  for(Color const& c: newColorMap->colors)
79  {
80  BOOST_CHECK_CLOSE(1, c.blue, accuracy);
81  }
82 
83  Color const currentColor = helper->getMonochromeColor();
84  BOOST_CHECK_CLOSE(Blue.red, currentColor.red, accuracy);
85  BOOST_CHECK_CLOSE(Blue.green, currentColor.green, accuracy);
86  BOOST_CHECK_CLOSE(Blue.blue, currentColor.blue, accuracy);
87 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( regular_colormaps_cant_have_their_colors_set  )
61 {
62  ColormapHelper::Ptr const helper = ColormapHelper::create(256);
63  BOOST_CHECK_THROW(helper->setMonochromeColor(Color(0, 0, 1)), std::runtime_error);
64 }
Here is the call graph for this function:

◆ BOOST_CHECK_EQUAL() [1/3]

BOOST_CHECK_EQUAL ( originalColormap  ,
colormap   
)

◆ BOOST_CHECK_EQUAL() [2/3]

BOOST_CHECK_EQUAL ( sample.  expectedColors,
colormap->colors.  size() 
)

◆ BOOST_CHECK_EQUAL() [3/3]

◆ BOOST_REQUIRE() [1/2]

BOOST_REQUIRE ( colormap  )

◆ BOOST_REQUIRE() [2/2]

BOOST_REQUIRE ( originalColormap  )

Referenced by BOOST_AUTO_TEST_CASE(), and DummyView::nextStatusMessage().

Here is the caller graph for this function:

Variable Documentation

◆ colormap

MonochromeColormapHelper::create
static Ptr create(int numberOfColors)
Definition: colormap-helpers.cc:72
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(sample.expectedColors, originalColormap->colors.size())
Color::blue
double blue
Definition: color.hh:42
MonochromeColormapHelper::createInverted
static Ptr createInverted(int numberOfColors)
Definition: colormap-helpers.cc:77
Color::red
double red
Definition: color.hh:40
Colormap::Ptr
boost::shared_ptr< Colormap > Ptr
Definition: colormappable.hh:31
Colormappable::Ptr
boost::shared_ptr< Colormappable > Ptr
Definition: colormappable.hh:116
ColormapHelper::create
static Ptr create(int numberOfColors)
Definition: colormap-helpers.cc:55
anonymous_namespace{colormaphelpers_test.cc}::accuracy
const double accuracy
Definition: colormaphelpers_test.cc:25
Color
Definition: color.hh:34
Color::green
double green
Definition: color.hh:41
anonymous_namespace{colormaphelpers_test.cc}::Blue
const Color Blue(0, 0, 1)