Skip to content

Commit 2234b68

Browse files
committed
test: Add tests for SGR off codes, underline subparams, and underline color reset
1 parent ffb555f commit 2234b68

10 files changed

Lines changed: 320 additions & 0 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<style>
8+
.fg { color: #AAAAAA }
9+
.bg { background: #000000 }
10+
.bg-white { background: #AAAAAA; user-select: none; }
11+
.fg-black { color: #000000 }
12+
.container {
13+
line-height: 18px;
14+
}
15+
.bold { font-weight: bold; }
16+
.italic { font-style: italic; }
17+
.underline { text-decoration-line: underline; }
18+
.strikethrough { text-decoration-line: line-through; }
19+
.dimmed { opacity: 0.4; }
20+
.hidden { opacity: 0; }
21+
span {
22+
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
23+
white-space: pre;
24+
line-height: 18px;
25+
}
26+
</style>
27+
</head>
28+
29+
<body class="bg">
30+
31+
<div class="container fg">
32+
<span class="bold">bold normal</span><br />
33+
<span class="bold dimmed">dim normal</span><br />
34+
<span class="bold italic dimmed">italic normal</span><br />
35+
<span class="underline bold italic dimmed">underline normal</span><br />
36+
<span class="bg-white">█████████████</span><br />
37+
<span class="fg-black underline bold italic dimmed">invert normal</span><br />
38+
<span class="bg-white">█████████████</span><br />
39+
<span class="fg-black underline bold italic dimmed hidden">hidden normal</span><br />
40+
<span class="bg-white">████████████████████</span><br />
41+
<span class="fg-black underline strikethrough bold italic dimmed hidden">strikethrough normal</span><br />
42+
<span class="bg-white">█████████████████████████████████</span><br />
43+
<span class="fg-black underline strikethrough bold italic dimmed hidden">all three no bold no italic plain</span><br />
44+
<br />
45+
<br />
46+
</div>
47+
48+
</body>
49+
</html>
Lines changed: 57 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bold normal
2+
dim normal
3+
italic normal
4+
underline normal
5+
invert normal
6+
hidden normal
7+
strikethrough normal
8+
all three no bold no italic plain

crates/anstyle-svg/tests/term.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,57 @@ fn custom_background_color_html() {
7373
snapbox::file!["custom_background_color.html": Text].raw()
7474
);
7575
}
76+
77+
#[test]
78+
fn sgr_off_codes() {
79+
let input = std::fs::read_to_string("tests/sgr_off_codes.vte").unwrap();
80+
let actual = anstyle_svg::Term::new().render_svg(&input);
81+
snapbox::assert_data_eq!(actual, snapbox::file!["sgr_off_codes.svg": Text].raw());
82+
}
83+
84+
#[test]
85+
fn sgr_off_codes_html() {
86+
let input = std::fs::read_to_string("tests/sgr_off_codes.vte").unwrap();
87+
let actual = anstyle_svg::Term::new().render_html(&input);
88+
snapbox::assert_data_eq!(actual, snapbox::file!["sgr_off_codes.html": Text].raw());
89+
}
90+
91+
#[test]
92+
fn underline_subparams() {
93+
let input = std::fs::read_to_string("tests/underline_subparams.vte").unwrap();
94+
let actual = anstyle_svg::Term::new().render_svg(&input);
95+
snapbox::assert_data_eq!(
96+
actual,
97+
snapbox::file!["underline_subparams.svg": Text].raw()
98+
);
99+
}
100+
101+
#[test]
102+
fn underline_subparams_html() {
103+
let input = std::fs::read_to_string("tests/underline_subparams.vte").unwrap();
104+
let actual = anstyle_svg::Term::new().render_html(&input);
105+
snapbox::assert_data_eq!(
106+
actual,
107+
snapbox::file!["underline_subparams.html": Text].raw()
108+
);
109+
}
110+
111+
#[test]
112+
fn underline_color_reset() {
113+
let input = std::fs::read_to_string("tests/underline_color_reset.vte").unwrap();
114+
let actual = anstyle_svg::Term::new().render_svg(&input);
115+
snapbox::assert_data_eq!(
116+
actual,
117+
snapbox::file!["underline_color_reset.svg": Text].raw()
118+
);
119+
}
120+
121+
#[test]
122+
fn underline_color_reset_html() {
123+
let input = std::fs::read_to_string("tests/underline_color_reset.vte").unwrap();
124+
let actual = anstyle_svg::Term::new().render_html(&input);
125+
snapbox::assert_data_eq!(
126+
actual,
127+
snapbox::file!["underline_color_reset.html": Text].raw()
128+
);
129+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<style>
8+
.fg { color: #AAAAAA }
9+
.bg { background: #000000 }
10+
.underline-ansi256-202 { text-decoration-line: underline; text-decoration-color: #FF5F00 }
11+
.underline-rgb-0080FF { text-decoration-line: underline; text-decoration-color: #0080FF }
12+
.underline-rgb-FF0000 { text-decoration-line: underline; text-decoration-color: #FF0000 }
13+
.container {
14+
line-height: 18px;
15+
}
16+
.underline { text-decoration-line: underline; }
17+
span {
18+
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
19+
white-space: pre;
20+
line-height: 18px;
21+
}
22+
</style>
23+
</head>
24+
25+
<body class="bg">
26+
27+
<div class="container fg">
28+
<span class="underline-rgb-FF0000 underline">red underline default color underline normal</span><br />
29+
<span class="underline-ansi256-202 underline">orange underline default color underline normal</span><br />
30+
<span class="underline-rgb-0080FF underline">blue underline default color underline normal</span><br />
31+
<br />
32+
</div>
33+
34+
</body>
35+
</html>
Lines changed: 33 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
red underline default color underline normal
2+
orange underline default color underline normal
3+
[58:2:0:128:255mblue underline default color underline normal
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<style>
8+
.fg { color: #AAAAAA }
9+
.bg { background: #000000 }
10+
.container {
11+
line-height: 18px;
12+
}
13+
.underline { text-decoration-line: underline; }
14+
.double-underline { text-decoration-line: underline; text-decoration-style: double; }
15+
.curly-underline { text-decoration-line: underline; text-decoration-style: wavy; }
16+
.dotted-underline { text-decoration-line: underline; text-decoration-style: dotted; }
17+
.dashed-underline { text-decoration-line: underline; text-decoration-style: dashed; }
18+
span {
19+
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
20+
white-space: pre;
21+
line-height: 18px;
22+
}
23+
</style>
24+
</head>
25+
26+
<body class="bg">
27+
28+
<div class="container fg">
29+
<span class="underline">underline</span><span> normal</span><br />
30+
<span class="double-underline">double normal</span><br />
31+
<span class="double-underline curly-underline">curly normal</span><br />
32+
<span class="double-underline curly-underline dotted-underline">dotted normal</span><br />
33+
<span class="double-underline curly-underline dotted-underline dashed-underline">dashed normal</span><br />
34+
<br />
35+
</div>
36+
37+
</body>
38+
</html>
Lines changed: 38 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
underline[4:0m normal
2+
[4:2mdouble[4:0m normal
3+
[4:3mcurly[4:0m normal
4+
[4:4mdotted[4:0m normal
5+
[4:5mdashed[4:0m normal

0 commit comments

Comments
 (0)