mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
ff2c6cab55
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.
16 lines
328 B
C++
16 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());
|
|
}
|
|
}
|