summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/rgb.txt20
-rw-r--r--test/test-assetFactory.cpp30
2 files changed, 50 insertions, 0 deletions
diff --git a/test/fixtures/rgb.txt b/test/fixtures/rgb.txt
new file mode 100644
index 0000000..2fab7af
--- /dev/null
+++ b/test/fixtures/rgb.txt
@@ -0,0 +1,20 @@
+127 255 0 chartreuse1
+190 190 190 x11 gray
+169 169 169 DarkGrey
+ 0 255 255 cyan
+173 173 173 gray68
+202 225 255 LightSteelBlue1
+ 72 209 204 medium turquoise
+224 238 224 honeydew2
+238 197 145 burlywood2
+205 133 63 peru
+ 28 28 28 gray11
+ 83 134 139 CadetBlue4
+139 76 57 salmon4
+238 232 170 pale goldenrod
+112 128 144 slate grey
+255 255 0 yellow1
+159 121 238 MediumPurple2
+190 190 190 gray
+ 66 66 66 grey26
+0 0 139 DarkBlue
diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp
index fd7a41d..89f6bf0 100644
--- a/test/test-assetFactory.cpp
+++ b/test/test-assetFactory.cpp
@@ -11,6 +11,7 @@
#include "gfx/gl/sceneRenderer.h"
#include "lib/collection.hpp"
#include "lib/location.hpp"
+#include "lib/stream_support.hpp"
#include "testMainWindow.h"
#include "ui/applicationBase.h"
@@ -180,3 +181,32 @@ BOOST_AUTO_TEST_CASE(brush47xml)
render(20);
}
BOOST_AUTO_TEST_SUITE_END();
+
+template<typename T> using InOut = std::tuple<T, T>;
+BOOST_DATA_TEST_CASE(normalizeColourName,
+ boost::unit_test::data::make<InOut<std::string>>({
+ {"", ""},
+ {"black", "black"},
+ {" black ", "black"},
+ {" b l a c k ", "black"},
+ {" B L A c k ", "black"},
+ {"BLAck ", "black"},
+ {"BLACK ", "black"},
+ {"BlAck ", "black"},
+ {"Bl Ack ", "black"},
+ }),
+ in_, exp)
+{
+ auto in {in_};
+ BOOST_CHECK_NO_THROW(AssetFactory::normalizeColourName(in));
+ BOOST_CHECK_EQUAL(in, exp);
+}
+
+BOOST_AUTO_TEST_CASE(parseX11RGB)
+{
+ const auto parsedColours = AssetFactory::parseX11RGB(FIXTURESDIR "rgb.txt");
+ BOOST_REQUIRE_EQUAL(parsedColours.size(), 20);
+ BOOST_CHECK_EQUAL(parsedColours.at("cyan"), AssetFactory::Colour(0, 255, 255));
+ BOOST_CHECK_EQUAL(parsedColours.at("slategrey"), AssetFactory::Colour(112, 128, 144));
+ BOOST_CHECK_EQUAL(parsedColours.at("lightsteelblue1"), AssetFactory::Colour(202, 225, 255));
+}