aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/css/css_value.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/libserver/css/css_value.cxx')
-rw-r--r--src/libserver/css/css_value.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx
index a2b4ba5d7..5e482b58f 100644
--- a/src/libserver/css/css_value.cxx
+++ b/src/libserver/css/css_value.cxx
@@ -18,6 +18,7 @@
#include "css_colors_list.hxx"
#include "frozen/unordered_map.h"
#include "frozen/string.h"
+#include "libutil/util.h"
#include "contrib/robin-hood/robin_hood.h"
#include "fmt/core.h"
@@ -339,10 +340,8 @@ auto css_value::debug_str() const -> std::string {
using T = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<T, css_color>) {
- ret += "color: r=" + std::to_string(arg.r) +
- "; g=" + std::to_string(arg.g) +
- "; b=" + std::to_string(arg.b) +
- "; a=" + std::to_string(arg.alpha);
+ ret += fmt::format("color: r={};g={};b={};alpha={}",
+ arg.r, arg.g, arg.b, arg.alpha);
}
else if constexpr (std::is_same_v<T, double>) {
ret += "size: " + std::to_string(arg);
@@ -386,6 +385,13 @@ TEST_SUITE("css values") {
CHECK(final_col == p.second);
}
}
+ TEST_CASE("css colors strings") {
+ for (const auto &p : css_colors_map) {
+ auto col_parsed = css_value::maybe_color_from_string(p.first);
+ auto final_col = col_parsed.value().to_color().value();
+ CHECK(final_col == p.second);
+ }
+ }
};
}