aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-05 15:38:37 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-05 15:38:37 -0500
commit9f9c519cbaa5384e666ffa2b5e1cf4f99780ba28 (patch)
tree6f4e0b348edcfd31d795d863722be358f4b2e99a /tests
parent2471941ad0ee28a0c27df3f007faa16ff7028fa8 (diff)
downloadvt100-rust-9f9c519cbaa5384e666ffa2b5e1cf4f99780ba28.tar.gz
vt100-rust-9f9c519cbaa5384e666ffa2b5e1cf4f99780ba28.zip
fix erasing cells in diff
also add more comprehensive tests
Diffstat (limited to 'tests')
-rw-r--r--tests/data/crawl/crawl18
-rw-r--r--tests/data/crawl/crawl101
-rw-r--r--tests/data/crawl/crawl111
-rw-r--r--tests/data/crawl/crawl121
-rw-r--r--tests/data/crawl/crawl131
-rw-r--r--tests/data/crawl/crawl141
-rw-r--r--tests/data/crawl/crawl151
-rw-r--r--tests/data/crawl/crawl161
-rw-r--r--tests/data/crawl/crawl171
-rw-r--r--tests/data/crawl/crawl181
-rw-r--r--tests/data/crawl/crawl191
-rw-r--r--tests/data/crawl/crawl21
-rw-r--r--tests/data/crawl/crawl201
-rw-r--r--tests/data/crawl/crawl211
-rw-r--r--tests/data/crawl/crawl221
-rw-r--r--tests/data/crawl/crawl231
-rw-r--r--tests/data/crawl/crawl241
-rw-r--r--tests/data/crawl/crawl251
-rw-r--r--tests/data/crawl/crawl261
-rw-r--r--tests/data/crawl/crawl271
-rw-r--r--tests/data/crawl/crawl281
-rw-r--r--tests/data/crawl/crawl291
-rw-r--r--tests/data/crawl/crawl31
-rw-r--r--tests/data/crawl/crawl301
-rw-r--r--tests/data/crawl/crawl41
-rw-r--r--tests/data/crawl/crawl51
-rw-r--r--tests/data/crawl/crawl61
-rw-r--r--tests/data/crawl/crawl71
-rw-r--r--tests/data/crawl/crawl81
-rw-r--r--tests/data/crawl/crawl91
-rw-r--r--tests/window_contents.rs46
31 files changed, 82 insertions, 1 deletions
diff --git a/tests/data/crawl/crawl1 b/tests/data/crawl/crawl1
new file mode 100644
index 0000000..48328c5
--- /dev/null
+++ b/tests/data/crawl/crawl1
@@ -0,0 +1,8 @@
+
+Player: doy
+Game: Crawl (0.18)
+Server: Public Crawl server: crawl.akrasiac.org
+Filename: 2016-08-15.01:36:02.ttyrec
+Time: (1471224962) Sun Aug 14 21:36:02 2016
+
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl10 b/tests/data/crawl/crawl10
new file mode 100644
index 0000000..bb80abe
--- /dev/null
+++ b/tests/data/crawl/crawl10
@@ -0,0 +1 @@
+Welcome, doy. Please select your species.a - Humanj - Trolls - Vine Stalkerb - High Elfk - Nagat - Demigodc - Deep Elfl - Centauru - Demonspawnd - Deep Dwarfm - Merfolkv - Mummye - Hill Orcn - Minotaurw - Ghoulf - Halflingo - Tengux - Vampireg - Koboldp - Draconiany - Felidh - Sprigganq - Gargoylez - Octopodei - Ogrer - FormicidHumans advance quickly in levels and have equal abilities in most skills.   + - Viable species* - Random species# - Viable character ! - Random character% - List aptitudes Space - Pick background first? - HelpTab - Human Necromancer \ No newline at end of file
diff --git a/tests/data/crawl/crawl11 b/tests/data/crawl/crawl11
new file mode 100644
index 0000000..c4b1bfc
--- /dev/null
+++ b/tests/data/crawl/crawl11
@@ -0,0 +1 @@
+ [?25h[?47l8 > \ No newline at end of file
diff --git a/tests/data/crawl/crawl12 b/tests/data/crawl/crawl12
new file mode 100644
index 0000000..115441f
--- /dev/null
+++ b/tests/data/crawl/crawl12
@@ -0,0 +1 @@
+[?1051l[?1052l[?1060l[?1061l \ No newline at end of file
diff --git a/tests/data/crawl/crawl13 b/tests/data/crawl/crawl13
new file mode 100644
index 0000000..19ac3d6
--- /dev/null
+++ b/tests/data/crawl/crawl13
@@ -0,0 +1 @@
+[?1051l[?1052l[?1060l[?1061h \ No newline at end of file
diff --git a/tests/data/crawl/crawl14 b/tests/data/crawl/crawl14
new file mode 100644
index 0000000..efa8c19
--- /dev/null
+++ b/tests/data/crawl/crawl14
@@ -0,0 +1 @@
+= \ No newline at end of file
diff --git a/tests/data/crawl/crawl15 b/tests/data/crawl/crawl15
new file mode 100644
index 0000000..efa8c19
--- /dev/null
+++ b/tests/data/crawl/crawl15
@@ -0,0 +1 @@
+= \ No newline at end of file
diff --git a/tests/data/crawl/crawl16 b/tests/data/crawl/crawl16
new file mode 100644
index 0000000..ab58084
--- /dev/null
+++ b/tests/data/crawl/crawl16
@@ -0,0 +1 @@
+7[?47h[?25l \ No newline at end of file
diff --git a/tests/data/crawl/crawl17 b/tests/data/crawl/crawl17
new file mode 100644
index 0000000..9ba9231
--- /dev/null
+++ b/tests/data/crawl/crawl17
@@ -0,0 +1 @@
+Welcome, doy. Please select your species.a - Humanj - Trolls - Vine Stalkerb - High Elfk - Nagat - Demigodc - Deep Elfl - Centauru - Demonspawnd - Deep Dwarfm - Merfolkv - Mummye - Hill Orcn - Minotaurw - Ghoulf - Halflingo - Tengux - Vampireg - Koboldp - Draconiany - Felidh - Sprigganq - Gargoylez - Octopodei - Ogrer - FormicidHumans advance quickly in levels and have equal abilities in most skills.   + - Viable species* - Random species# - Viable character ! - Random character% - List aptitudes Space - Pick background first? - HelpTab - Human Necromancer \ No newline at end of file
diff --git a/tests/data/crawl/crawl18 b/tests/data/crawl/crawl18
new file mode 100644
index 0000000..c97699c
--- /dev/null
+++ b/tests/data/crawl/crawl18
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl19 b/tests/data/crawl/crawl19
new file mode 100644
index 0000000..26fad4e
--- /dev/null
+++ b/tests/data/crawl/crawl19
@@ -0,0 +1 @@
+doy the Grave Robber HumanHealth: 13/13 ========================Magic: 3/3========================AC:  2Str: 8EV: 12Int: 15SH:  0Dex: 13XL:  1 Next:  0%  Place: Dungeon:1Gold: 0Time: 0.0 (0.0)-) Nothing wielded-) Nothing quivered \ No newline at end of file
diff --git a/tests/data/crawl/crawl2 b/tests/data/crawl/crawl2
new file mode 100644
index 0000000..9d99541
--- /dev/null
+++ b/tests/data/crawl/crawl2
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl20 b/tests/data/crawl/crawl20
new file mode 100644
index 0000000..39c81b8
--- /dev/null
+++ b/tests/data/crawl/crawl20
@@ -0,0 +1 @@
+ #### #p.# ##....... ....... #...(.. ..#.#. .#. # ### \ No newline at end of file
diff --git a/tests/data/crawl/crawl21 b/tests/data/crawl/crawl21
new file mode 100644
index 0000000..16cb040
--- /dev/null
+++ b/tests/data/crawl/crawl21
@@ -0,0 +1 @@
+  Welcome, doy the Human Necromancer.Will you prevail where others failed? Will you find the Orb of Zot? \ No newline at end of file
diff --git a/tests/data/crawl/crawl22 b/tests/data/crawl/crawl22
new file mode 100644
index 0000000..d84b899
--- /dev/null
+++ b/tests/data/crawl/crawl22
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl23 b/tests/data/crawl/crawl23
new file mode 100644
index 0000000..d53987d
--- /dev/null
+++ b/tests/data/crawl/crawl23
@@ -0,0 +1 @@
+Press ? for a list of commands and other information.  Found 10 sling bullets. \ No newline at end of file
diff --git a/tests/data/crawl/crawl24 b/tests/data/crawl/crawl24
new file mode 100644
index 0000000..d84b899
--- /dev/null
+++ b/tests/data/crawl/crawl24
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl25 b/tests/data/crawl/crawl25
new file mode 100644
index 0000000..bb5d42e
--- /dev/null
+++ b/tests/data/crawl/crawl25
@@ -0,0 +1 @@
+ _Found a staircase leading out of the dungeon. \ No newline at end of file
diff --git a/tests/data/crawl/crawl26 b/tests/data/crawl/crawl26
new file mode 100644
index 0000000..765cd31
--- /dev/null
+++ b/tests/data/crawl/crawl26
@@ -0,0 +1 @@
+ _#######<.#p####.#3.0 (3#..##...#......#>#.#.##..#.###### ## _Found an escape hatch in the floor. \ No newline at end of file
diff --git a/tests/data/crawl/crawl27 b/tests/data/crawl/crawl27
new file mode 100644
index 0000000..d0906bf
--- /dev/null
+++ b/tests/data/crawl/crawl27
@@ -0,0 +1 @@
+ _ _There is an escape hatch in the floor here. \ No newline at end of file
diff --git a/tests/data/crawl/crawl28 b/tests/data/crawl/crawl28
new file mode 100644
index 0000000..20add35
--- /dev/null
+++ b/tests/data/crawl/crawl28
@@ -0,0 +1 @@
+ _You see here 10 sling bullets. \ No newline at end of file
diff --git a/tests/data/crawl/crawl29 b/tests/data/crawl/crawl29
new file mode 100644
index 0000000..499d593
--- /dev/null
+++ b/tests/data/crawl/crawl29
@@ -0,0 +1 @@
+ ##...#.#...#.#  #>#.#.##..#..# ############.# #.######## #......... #.######## #######.######## ................ ######p########25.0 (22.0) ..#  >.  ........##  #####.#.#   #...#   ###.#  #.#  \ No newline at end of file
diff --git a/tests/data/crawl/crawl3 b/tests/data/crawl/crawl3
new file mode 100644
index 0000000..19ac3d6
--- /dev/null
+++ b/tests/data/crawl/crawl3
@@ -0,0 +1 @@
+[?1051l[?1052l[?1060l[?1061h \ No newline at end of file
diff --git a/tests/data/crawl/crawl30 b/tests/data/crawl/crawl30
new file mode 100644
index 0000000..b8bd936
--- /dev/null
+++ b/tests/data/crawl/crawl30
@@ -0,0 +1 @@
+ _Found a stone staircase leading down. \ No newline at end of file
diff --git a/tests/data/crawl/crawl4 b/tests/data/crawl/crawl4
new file mode 100644
index 0000000..e4a08bc
--- /dev/null
+++ b/tests/data/crawl/crawl4
@@ -0,0 +1 @@
+(B)07[?47h= \ No newline at end of file
diff --git a/tests/data/crawl/crawl5 b/tests/data/crawl/crawl5
new file mode 100644
index 0000000..a4e3d21
--- /dev/null
+++ b/tests/data/crawl/crawl5
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl6 b/tests/data/crawl/crawl6
new file mode 100644
index 0000000..4f9e18b
--- /dev/null
+++ b/tests/data/crawl/crawl6
@@ -0,0 +1 @@
+[?25l \ No newline at end of file
diff --git a/tests/data/crawl/crawl7 b/tests/data/crawl/crawl7
new file mode 100644
index 0000000..c97699c
--- /dev/null
+++ b/tests/data/crawl/crawl7
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl8 b/tests/data/crawl/crawl8
new file mode 100644
index 0000000..c97699c
--- /dev/null
+++ b/tests/data/crawl/crawl8
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/data/crawl/crawl9 b/tests/data/crawl/crawl9
new file mode 100644
index 0000000..c97699c
--- /dev/null
+++ b/tests/data/crawl/crawl9
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/tests/window_contents.rs b/tests/window_contents.rs
index 723e0d8..32921b8 100644
--- a/tests/window_contents.rs
+++ b/tests/window_contents.rs
@@ -1,3 +1,5 @@
+use std::io::Read as _;
+
#[test]
fn formatted() {
let mut parser = vt100::Parser::new(24, 80);
@@ -339,7 +341,7 @@ fn diff() {
parser.process(b"\x1b[1;8H\x1b[X");
let screen5 = parser.screen().clone();
- assert_eq!(screen5.contents_diff(&screen4), b"\x1b[1;8H\x1b[X");
+ assert_eq!(screen5.contents_diff(&screen4), b"\x1b[1;8H\x1b[X\x1b[C");
compare_diff(
&screen4,
&screen5,
@@ -347,6 +349,34 @@ fn diff() {
);
}
+#[test]
+fn diff_crawl() {
+ let mut parser = vt100::Parser::new(24, 80);
+ let screens: Vec<_> = (1..=30)
+ .map(|i| {
+ let mut file =
+ std::fs::File::open(format!("tests/data/crawl/crawl{}", i))
+ .unwrap();
+ let mut frame = vec![];
+ file.read_to_end(&mut frame).unwrap();
+ parser.process(&frame);
+ (frame.clone(), parser.screen().clone())
+ })
+ .collect();
+
+ let mut all_frames: Vec<u8> = vec![];
+ for two_screens in screens.windows(2) {
+ eprintln!("loop");
+ match two_screens {
+ [(prev_frame, prev_screen), (_, screen)] => {
+ all_frames.extend(prev_frame);
+ compare_diff(prev_screen, screen, &all_frames);
+ }
+ _ => unreachable!(),
+ }
+ }
+}
+
fn compare_formatted(screen: &vt100::Screen) {
let (rows, cols) = screen.size();
let mut parser = vt100::Parser::new(rows, cols);
@@ -370,6 +400,20 @@ fn compare_diff(
compare_cells(parser.screen(), &prev_screen);
parser.process(&screen.contents_diff(prev_screen));
+ if parser.screen().contents_formatted() != screen.contents_formatted() {
+ use std::io::Write as _;
+ let mut prev_screen_file =
+ std::fs::File::create("prev_screen").unwrap();
+ prev_screen_file
+ .write_all(&prev_screen.contents_formatted())
+ .unwrap();
+ let mut screen_file = std::fs::File::create("screen").unwrap();
+ screen_file.write_all(&screen.contents_formatted()).unwrap();
+ let mut diff_file = std::fs::File::create("diff").unwrap();
+ diff_file
+ .write_all(&screen.contents_diff(prev_screen))
+ .unwrap();
+ }
assert_eq!(
parser.screen().contents_formatted(),
screen.contents_formatted()