blob: 8549c895ab8f96d220c93e7c3843a343ac65c60e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
use svgbob::Settings;
#[test]
fn rect1() {
let bob = r#"
+----------+
| |
+----------+
"#;
let expected = r#"<svg xmlns="http://www.w3.org/2000/svg" width="136" height="80">
<rect x="36" y="24" width="88" height="32" class="solid nofill" rx="0"></rect>
</svg>"#;
let svg = svgbob::to_svg_with_settings(bob, &Settings::for_debug());
println!("{}", svg);
assert_eq!(expected, svg);
}
#[test]
fn escaped_shape() {
let bob = r#"
"+----------+"
"| |"
"+----------+"
"#;
let expected = r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="32">
<text x="34" y="28" >+----------+</text>
<text x="34" y="44" >| |</text>
<text x="34" y="60" >+----------+</text>
</svg>"#;
let svg = svgbob::to_svg_with_settings(bob, &Settings::for_debug());
println!("{}", svg);
assert_eq!(expected, svg);
}
#[test]
fn rounded_rect() {
let bob = r#"
.----------.
| |
'----------'
"#;
let expected = r#"<svg xmlns="http://www.w3.org/2000/svg" width="136" height="80">
<rect x="36" y="24" width="88" height="32" class="solid nofill" rx="4"></rect>
</svg>"#;
let svg = svgbob::to_svg_with_settings(bob, &Settings::for_debug());
println!("{}", svg);
assert_eq!(expected, svg);
}
|