mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 21:37:58 +03:00
Truncating the value is mathematically incorrect, this error made the conversion to grayscale unstable. In other world, calling `to_grayscale` on a gray value would return a different value. As an example, `Color::from_string("#686868ff"sv).to_grayscale()` used to return #676767ff.
17 lines
328 B
C++
17 lines
328 B
C++
/*
|
|
* Copyright (c) 2024, Lucas Chollet <lucas.chollet@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibGfx/Color.h>
|
|
#include <LibTest/TestCase.h>
|
|
|
|
TEST_CASE(color)
|
|
{
|
|
for (u16 i = 0; i < 256; ++i) {
|
|
auto const gray = Color(i, i, i);
|
|
EXPECT_EQ(gray, gray.to_grayscale());
|
|
}
|
|
}
|