colorspace_oklab.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SuperTux
  2. // Copyright (C) 2015 Ingo Ruhnke <grumbel@gmail.com>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include "util/colorspace_oklab.hpp"
  17. #include <gtest/gtest.h>
  18. #include "video/color.hpp"
  19. TEST(ColorOKLCh, ctor)
  20. {
  21. ColorOKLCh color(.3f, .4f, .5f);
  22. // Can't use strict equality because of imprecision
  23. // 1 / 256 = 0.00390625, so 0.001 should make no difference.
  24. EXPECT_NEAR(color.L, .3f, 0.001f);
  25. EXPECT_NEAR(color.C, .4f, 0.001f);
  26. EXPECT_NEAR(color.h, .5f, 0.001f);
  27. }
  28. TEST(ColorOKLCh, ctor_Color)
  29. {
  30. Color col(.3f, .4f, .5f);
  31. ColorOKLCh color(col);
  32. EXPECT_NEAR(color.L, .50023675f, 0.001f);
  33. EXPECT_NEAR(color.C, .050982524f, 0.001f);
  34. EXPECT_NEAR(color.h, -1.9393998f, 0.001f);
  35. }
  36. /* EOF */