More ansi styling tests

This commit is contained in:
Kovid Goyal 2022-08-28 09:11:13 +05:30
parent 42a8ca0842
commit 29d9b70f0c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 1 deletions

View File

@ -281,7 +281,7 @@ func (self *sgr_code) update() {
p, s = self.dim.as_sgr("2", "22", p, s) p, s = self.dim.as_sgr("2", "22", p, s)
p, s = self.underline.as_sgr(p, s) p, s = self.underline.as_sgr(p, s)
p, s = self.fg.as_sgr(30, p, s) p, s = self.fg.as_sgr(30, p, s)
p, s = self.bg.as_sgr(30, p, s) p, s = self.bg.as_sgr(40, p, s)
p, s = self.uc.as_sgr(50, p, s) p, s = self.uc.as_sgr(50, p, s)
self._prefix = "\x1b[" + strings.Join(p, ";") + "m" self._prefix = "\x1b[" + strings.Join(p, ";") + "m"
self._suffix = "\x1b[" + strings.Join(s, ";") + "m" self._suffix = "\x1b[" + strings.Join(s, ";") + "m"

View File

@ -34,5 +34,12 @@ func TestANSIStyleSprint(t *testing.T) {
test("bold", "\x1b[1m", "\x1b[22m") test("bold", "\x1b[1m", "\x1b[22m")
test("bold fg=red u=curly", "\x1b[1;4:3;31m", "\x1b[22;4:0;39m") test("bold fg=red u=curly", "\x1b[1;4:3;31m", "\x1b[22;4:0;39m")
test("fg=123", "\x1b[38:5:123m", "\x1b[39m")
test("fg=15", "\x1b[97m", "\x1b[39m")
test("bg=15", "\x1b[107m", "\x1b[49m")
test("fg=#123", "\x1b[38:2:17:34:51m", "\x1b[39m")
test("fg=rgb:1/2/3", "\x1b[38:2:1:2:3m", "\x1b[39m")
test("bg=123", "\x1b[48:5:123m", "\x1b[49m")
test("uc=123", "\x1b[58:2:135:255:255m", "\x1b[59m")
} }