From d78d692efcc734195515fd060a1f35cb5123a72d Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Thu, 2 May 2024 13:03:30 +0200 Subject: [PATCH] t/t4026-color: add test coverage for invalid RGB colors Make sure that the RGB color parser rejects invalid characters and invalid lengths. Signed-off-by: Beat Bolli Signed-off-by: Junio C Hamano --- t/t4026-color.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/t/t4026-color.sh b/t/t4026-color.sh index 37622451fc..c411380319 100755 --- a/t/t4026-color.sh +++ b/t/t4026-color.sh @@ -140,6 +140,24 @@ test_expect_success 'extra character after attribute' ' invalid_color "dimX" ' +test_expect_success 'non-hex character in RGB color' ' + invalid_color "#x23456" && + invalid_color "#1x3456" && + invalid_color "#12x456" && + invalid_color "#123x56" && + invalid_color "#1234x6" && + invalid_color "#12345x" +' + +test_expect_success 'wrong number of letters in RGB color' ' + invalid_color "#1" && + invalid_color "#23" && + invalid_color "#456" && + invalid_color "#789a" && + invalid_color "#bcdef" && + invalid_color "#1234567" +' + test_expect_success 'unknown color slots are ignored (diff)' ' git config color.diff.nosuchslotwilleverbedefined white && git diff --color