summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2021-06-15 08:59:02 +0200
committercos <cos>2021-06-15 09:12:08 +0200
commitfde50cfc7ab67d52172a144cbc4b478c4075c294 (patch)
treebc05f6a7ecf28e46885e3048bb85cdd45bc76c6c
parenta3fd9c4da77ceef1d35bc530bc4bce42ab4337aa (diff)
downloaddotavious-fde50cfc7ab67d52172a144cbc4b478c4075c294.zip
Update test cases for IDsfix/allow_id_strings
Ideally there should be test cases validating that strings longer than 80 characters are getting line breaks injected, but such tests would likely fail.
-rw-r--r--tests/dot.rs54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/dot.rs b/tests/dot.rs
index 9d944a2..f0c61aa 100644
--- a/tests/dot.rs
+++ b/tests/dot.rs
@@ -63,6 +63,58 @@ digraph {
}
#[test]
+fn nonreadable_ascii_id() {
+ let id = "\u{0}\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\u{9}\u{a}\u{b}\u{c}\u{d}\u{e}\u{f}\
+ \u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\u{18}\u{19}\u{1a}\u{1b}\u{1c}\u{1d}\u{1e}\
+ \u{1f}";
+
+ let g = GraphBuilder::new_named_directed(id)
+ .build()
+ .unwrap();
+ let r = test_input(g);
+ assert_eq!(
+ r.unwrap(),
+ "digraph \"\u{0}\u{1}\u{2}\u{3}\u{4}\u{5}\u{6}\u{7}\u{8}\u{9}\u{a}\u{b}\u{c}\u{d}\u{e}\
+ \u{f}\u{10}\u{11}\u{12}\u{13}\u{14}\u{15}\u{16}\u{17}\u{18}\u{19}\u{1a}\u{1b}\u{1c}\
+ \u{1d}\u{1e}\u{1f}\" {
+}
+"
+ );
+}
+
+#[test]
+fn readable_ascii_no_alphanum_id() {
+ let id = r##" !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"##;
+
+ let g = GraphBuilder::new_named_directed(id)
+ .build()
+ .unwrap();
+ let r = test_input(g);
+ assert_eq!(
+ r.unwrap(),
+ r##"digraph " !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~" {
+}
+"##
+ );
+}
+
+#[test]
+fn non_ascii_alphanum_id() {
+ let id = "Identität";
+
+ let g = GraphBuilder::new_named_directed(id)
+ .build()
+ .unwrap();
+ let r = test_input(g);
+ assert_eq!(
+ r.unwrap(),
+ r##"digraph Identität {
+}
+"##
+ );
+}
+
+#[test]
fn quotted_id() {
let quotted_id = r#"Earvin "Magic" Johnson"#;
let g = GraphBuilder::new_named_directed(quotted_id)
@@ -316,7 +368,7 @@ fn edge_statement_port_position() {
r#"digraph edge_statement_port_position {
N0 [shape=record, label="a|<port0>b"];
N1 [shape=record, label="e|<port1>f"];
- N0:port0:sw -> N1:port1:ne;
+ "N0:port0:sw" -> "N1:port1:ne";
}
"#
);