extra product info
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Jun 2025 19:39:02 +0000 (12:39 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Jun 2025 19:39:02 +0000 (12:39 -0700)
rust/pspp/src/sys/test.rs
rust/pspp/src/sys/testdata/extra_product_info.expected [new file with mode: 0644]
rust/pspp/src/sys/testdata/extra_product_info.sack [new file with mode: 0644]

index 7a7801e27b65cf0fd76dc7d950b52a46bfc3cba7..db94531a2faa527bf62ddac5654c26d0cee46373 100644 (file)
@@ -55,6 +55,13 @@ fn multiple_response_sets() {
     test_sysfile("multiple_response_sets");
 }
 
+#[test]
+fn extra_product_info() {
+    // Also checks for handling of CR-only line ends in file label and extra
+    // product info.
+    test_sysfile("extra_product_info");
+}
+
 fn test_sysfile(name: &str) {
     let input_filename = Path::new(env!("CARGO_MANIFEST_DIR"))
         .join("src/sys/testdata")
diff --git a/rust/pspp/src/sys/testdata/extra_product_info.expected b/rust/pspp/src/sys/testdata/extra_product_info.expected
new file mode 100644 (file)
index 0000000..63ef54f
--- /dev/null
@@ -0,0 +1,26 @@
+╭──────────────────────┬────────────────────────╮
+│       Created        │    01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product        │PSPP synthetic test file│
+│       Product 2      │Extra product info      │
+│                      │another line            │
+│                      │blah                    │
+├──────────────────────┼────────────────────────┤
+│       Compression    │None                    │
+│       Number of Cases│                       0│
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬──────────────╮
+│Label    │PSPP synthetic│
+│         │test file     │
+│Variables│             4│
+╰─────────┴──────────────╯
+
+╭─┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│ │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├─┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│a│       1│     │                 │Input│    8│Right    │F8.0        │F8.0        │              │
+│b│       2│     │                 │Input│    8│Right    │F8.0        │F8.0        │              │
+│c│       3│     │                 │Input│    8│Right    │F8.0        │F8.0        │              │
+│d│       4│     │                 │Input│    8│Right    │F8.0        │F8.0        │              │
+╰─┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
diff --git a/rust/pspp/src/sys/testdata/extra_product_info.sack b/rust/pspp/src/sys/testdata/extra_product_info.sack
new file mode 100644 (file)
index 0000000..d909737
--- /dev/null
@@ -0,0 +1,25 @@
+# File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; # Layout code
+4; # Nominal case size
+0; # Not compressed
+0; # Not weighted
+0; # No cases.
+100.0; # Bias.
+"01 Jan 11"; "20:53:52"; "PSPP synthetic"; i8 13; s49 "test file";
+i8 0 *3;
+
+# Numeric variables.
+2; 0; 0; 0; 0x050800 *2; s8 "A";
+2; 0; 0; 0; 0x050800 *2; s8 "B";
+2; 0; 0; 0; 0x050800 *2; s8 "C";
+2; 0; 0; 0; 0x050800 *2; s8 "D";
+
+# Extra product info.
+7; 10; 1; COUNT ("Extra product info"; i8 13; "another line"; i8 13; "blah");
+
+# Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+# Dictionary termination record.
+999; 0;