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 <dev+git@drbeat.li>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Beat Bolli 2024-05-02 13:03:30 +02:00 committed by Junio C Hamano
parent e95af749a2
commit d78d692efc

View file

@ -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