test_color.cpp 767 B

1234567891011121314151617181920212223
  1. #include <catch2/catch.hpp>
  2. #include "libslic3r/libslic3r.h"
  3. #include "libslic3r/Color.hpp"
  4. using namespace Slic3r;
  5. SCENARIO("Color encoding/decoding cycle", "[Color]") {
  6. GIVEN("Color") {
  7. const ColorRGB src_rgb(static_cast<unsigned char>(255), static_cast<unsigned char>(127), static_cast<unsigned char>(63));
  8. WHEN("apply encode/decode cycle") {
  9. const std::string encoded = encode_color(src_rgb);
  10. ColorRGB res_rgb;
  11. decode_color(encoded, res_rgb);
  12. const bool ret = res_rgb.r_uchar() == src_rgb.r_uchar() && res_rgb.g_uchar() == src_rgb.g_uchar() && res_rgb.b_uchar() == src_rgb.b_uchar();
  13. THEN("result matches source") {
  14. REQUIRE(ret);
  15. }
  16. }
  17. }
  18. }