From 9b6cea5a1305a1fcea2e09daab52aea797b958c2 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 7 Dec 2017 10:45:04 +0100 Subject: [PATCH] Add unit tests for gears.color.ensure_pango_color Signed-off-by: Uli Schlachter --- spec/gears/color_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/gears/color_spec.lua b/spec/gears/color_spec.lua index 2ac33eab8..89b0b1b50 100644 --- a/spec/gears/color_spec.lua +++ b/spec/gears/color_spec.lua @@ -267,6 +267,25 @@ describe("gears.color", function() assert.is_not.equal(color.create_pattern_uncached("#00ff00"), color.create_pattern_uncached("#00ff00")) end) end) + + describe("ensure_pango_color", function() + -- Successful cases + for _, value in ipairs{ "red", "cyan", "black", "#f00", "#014578", + "#01ef01ef01ef" + } do + it(value, function() + assert.is.same(value, color.ensure_pango_color(value)) + end) + end + + it("#abz", function() + assert.is.same("black", color.ensure_pango_color("#abz")) + end) + + it("fallback", function() + assert.is.same("zzz", color.ensure_pango_color("#abz", "zzz")) + end) + end) end) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80