add test
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 17 Jun 2025 20:33:59 +0000 (13:33 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 17 Jun 2025 20:33:59 +0000 (13:33 -0700)
rust/pspp/src/sys/test.rs
rust/pspp/src/sys/testdata/bad_machine_float_info_size.expected [new file with mode: 0644]
rust/pspp/src/sys/testdata/bad_machine_float_info_size.sack [new file with mode: 0644]

index 3caabc81c9dec36711f3a7b33c5ab07aac6658e2..479f1d623c3d7a3b2a6096ffd173d9d8bd2c324f 100644 (file)
@@ -217,6 +217,11 @@ fn bad_machine_integer_info_endianness() {
     test_sysfile("bad_machine_integer_info_endianness");
 }
 
+#[test]
+fn bad_machine_float_info_size() {
+    test_sysfile("bad_machine_float_info_size");
+}
+
 /// Duplicate variable name handling negative test.
 ///
 /// SPSS-generated system file can contain duplicate variable names (see bug
diff --git a/rust/pspp/src/sys/testdata/bad_machine_float_info_size.expected b/rust/pspp/src/sys/testdata/bad_machine_float_info_size.expected
new file mode 100644 (file)
index 0000000..973ebaa
--- /dev/null
@@ -0,0 +1,20 @@
+At offset 0xe0, floating point record has bad count 4 instead of the expected 3.
+
+╭──────────────────────┬────────────────────────╮
+│       Created        │    01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product        │PSPP synthetic test file│
+├──────────────────────┼────────────────────────┤
+│       Compression    │SAV                     │
+│       Number of Cases│Unknown                 │
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬─╮
+│Variables│1│
+╰─────────┴─╯
+
+╭────┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│    │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├────┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│num1│       1│     │                 │Input│    8│Right    │F8.0        │F8.0        │              │
+╰────┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
diff --git a/rust/pspp/src/sys/testdata/bad_machine_float_info_size.sack b/rust/pspp/src/sys/testdata/bad_machine_float_info_size.sack
new file mode 100644 (file)
index 0000000..ef5a83c
--- /dev/null
@@ -0,0 +1,15 @@
+# File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
+
+# Numeric variable, no label or missing values.
+2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
+
+# Machine floating-point info record.
+7; 4; 8; >>4<<; SYSMIS; HIGHEST; LOWEST; 0.0;
+
+# Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+# End of dictionary.
+999; 0;