From 83c4dc85adf03d22b8e7c0ac56abfdaced84edf8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 20 Dec 2016 18:47:21 +0300 Subject: Add unit tests for S and A dye with 2, 4, 8 pixels. --- src/resources/dye/dye_unittest.cc | 198 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) (limited to 'src/resources') diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc index 924ac39fd..36e398343 100644 --- a/src/resources/dye/dye_unittest.cc +++ b/src/resources/dye/dye_unittest.cc @@ -89,6 +89,55 @@ TEST_CASE("Dye replaceSOGLColor 3") REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10)); } +TEST_CASE("Dye replaceSOGLColor 4") +{ + DyePalette palette("#01ff02,030411", 6); + uint32_t data[2]; + data[0] = buildHex(0x20, 0x02, 0xff, 0x01); + data[1] = buildHex(0x30, 0x02, 0xff, 0x01); + palette.replaceSOGLColor(&data[0], 2); + REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03)); +} + +TEST_CASE("Dye replaceSOGLColor 5") +{ + DyePalette palette("#01ff02,030411", 6); + uint32_t data[4]; + data[0] = buildHex(0x20, 0x02, 0xff, 0x01); + data[1] = buildHex(0x30, 0x02, 0xff, 0x01); + data[2] = buildHex(0x40, 0x02, 0xff, 0x01); + data[3] = buildHex(0x50, 0x02, 0xff, 0x02); + palette.replaceSOGLColor(&data[0], 4); + REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02)); +} + +TEST_CASE("Dye replaceSOGLColor 6") +{ + DyePalette palette("#01ff02,030411,01ee02,010203", 6); + uint32_t data[8]; + data[0] = buildHex(0x20, 0x02, 0xff, 0x01); + data[1] = buildHex(0x30, 0x02, 0xff, 0x01); + data[2] = buildHex(0x40, 0x02, 0xff, 0x01); + data[3] = buildHex(0x50, 0x02, 0xff, 0x02); + data[4] = buildHex(0x20, 0x02, 0xff, 0x01); + data[5] = buildHex(0x30, 0x02, 0xff, 0x01); + data[6] = buildHex(0x40, 0x02, 0xff, 0x01); + data[7] = buildHex(0x60, 0x02, 0xff, 0x02); + palette.replaceSOGLColor(&data[0], 8); + REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02)); + REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03)); + REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03)); + REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03)); + REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02)); +} + TEST_CASE("Dye replaceAOGLColor 1") { @@ -117,6 +166,55 @@ TEST_CASE("Dye replaceAOGLColor 3") REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); } +TEST_CASE("Dye replaceAOGLColor 4") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[2]; + data[0] = buildHex(0x40, 0xee, 0x00, 0x01); + data[1] = buildHex(0x40, 0xee, 0x00, 0x01); + palette.replaceAOGLColor(&data[0], 2); + REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10)); +} + +TEST_CASE("Dye replaceAOGLColor 5") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[4]; + data[0] = buildHex(0x40, 0xee, 0x00, 0x01); + data[1] = buildHex(0x40, 0xee, 0x00, 0x01); + data[2] = buildHex(0x41, 0xee, 0x00, 0x01); + data[3] = buildHex(0x40, 0xee, 0x00, 0x01); + palette.replaceAOGLColor(&data[0], 4); + REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01)); + REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10)); +} + +TEST_CASE("Dye replaceAOGLColor 6") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[8]; + data[0] = buildHex(0x40, 0xee, 0x00, 0x01); + data[1] = buildHex(0x40, 0xee, 0x00, 0x01); + data[2] = buildHex(0x41, 0xee, 0x00, 0x01); + data[3] = buildHex(0x40, 0xee, 0x00, 0x01); + data[4] = buildHex(0x40, 0xee, 0x00, 0x01); + data[5] = buildHex(0x40, 0x40, 0x40, 0x40); + data[6] = buildHex(0x41, 0xe0, 0x00, 0x01); + data[7] = buildHex(0x40, 0xee, 0x00, 0x01); + palette.replaceAOGLColor(&data[0], 8); + REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01)); + REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10)); + REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20)); + REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01)); + REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10)); +} + TEST_CASE("Dye replaceSColor 1") { @@ -145,6 +243,55 @@ TEST_CASE("Dye replaceSColor 3") REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); } +TEST_CASE("Dye replaceSColor 4") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[2]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColor(&data[0], 2); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); +} + +TEST_CASE("Dye replaceSColor 5") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[4]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + palette.replaceSColor(&data[0], 4); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); +} + +TEST_CASE("Dye replaceSColor 6") +{ + DyePalette palette("#123456,000000,ff3020,706050", 6); + uint32_t data[8]; + data[0] = buildHex(0xff, 0x30, 0x20, 0x10); + data[1] = buildHex(0xff, 0x30, 0x20, 0x20); + data[2] = buildHex(0xff, 0x40, 0x20, 0x10); + data[3] = buildHex(0xff, 0x30, 0x20, 0x20); + data[4] = buildHex(0xff, 0x30, 0x20, 0x10); + data[5] = buildHex(0xff, 0x30, 0x20, 0x40); + data[6] = buildHex(0xff, 0x40, 0x20, 0x50); + data[7] = buildHex(0xff, 0x30, 0x20, 0x60); + palette.replaceSColor(&data[0], 8); + REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10)); + REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20)); + REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10)); + REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40)); + REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50)); + REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60)); +} + TEST_CASE("Dye replaceAColor 1") { @@ -173,6 +320,56 @@ TEST_CASE("Dye replaceAColor 3") REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); } +TEST_CASE("Dye replaceAColor 4") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[2]; + data[0] = buildHex(0x01, 0x00, 0xee, 0x40); + data[1] = buildHex(0x40, 0x40, 0x40, 0x40); + palette.replaceAColor(&data[0], 2); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); + REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00)); +} + +TEST_CASE("Dye replaceAColor 5") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[4]; + data[0] = buildHex(0x01, 0x00, 0xee, 0x40); + data[1] = buildHex(0x40, 0x40, 0x40, 0x40); + data[2] = buildHex(0x01, 0x00, 0xee, 0x50); + data[3] = buildHex(0x40, 0x40, 0x40, 0x40); + palette.replaceAColor(&data[0], 4); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); + REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00)); + REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50)); + REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00)); +} + +TEST_CASE("Dye replaceAColor 6") +{ + DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8); + uint32_t data[8]; + data[0] = buildHex(0x01, 0x00, 0xee, 0x40); + data[1] = buildHex(0x40, 0x40, 0x40, 0x40); + data[2] = buildHex(0x01, 0x00, 0xee, 0x50); + data[3] = buildHex(0x40, 0x40, 0x40, 0x40); + data[4] = buildHex(0x01, 0x00, 0xee, 0x40); + data[5] = buildHex(0x40, 0x40, 0x41, 0x40); + data[6] = buildHex(0x01, 0x00, 0xee, 0x50); + data[7] = buildHex(0x40, 0x40, 0x40, 0x40); + palette.replaceAColor(&data[0], 8); + REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff)); + REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00)); + REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50)); + REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00)); + REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff)); + REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40)); + REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50)); + REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00)); +} + + TEST_CASE("Dye normalDye 1") { Dye dye("R:#203040,506070"); @@ -191,6 +388,7 @@ TEST_CASE("Dye normalDye 2") REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x60)); } + TEST_CASE("Dye normalOGLDye 1") { Dye dye("R:#203040,506070"); -- cgit v1.2.3-70-g09d2