more variable display
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Jun 2025 19:51:00 +0000 (12:51 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 8 Jun 2025 19:51:00 +0000 (12:51 -0700)
rust/pspp/src/sys/test.rs
rust/pspp/src/sys/testdata/variable_display_with_width.expected [new file with mode: 0644]
rust/pspp/src/sys/testdata/variable_display_with_width.sack [new file with mode: 0644]
rust/pspp/src/sys/testdata/variable_display_without_width.expected

index 3265db5c4834f6b1dcde277bff7e6dd3d2c46402..eb51ecf126aa1355be7a3350b6dc656dba60f400 100644 (file)
@@ -67,6 +67,11 @@ fn variable_display_without_width() {
     test_sysfile("variable_display_without_width");
 }
 
+#[test]
+fn variable_display_with_width() {
+    test_sysfile("variable_display_with_width");
+}
+
 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/variable_display_with_width.expected b/rust/pspp/src/sys/testdata/variable_display_with_width.expected
new file mode 100644 (file)
index 0000000..a90f718
--- /dev/null
@@ -0,0 +1,30 @@
+╭──────────────────────┬────────────────────────╮
+│       Created        │    01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product        │PSPP synthetic test file│
+├──────────────────────┼────────────────────────┤
+│       Compression    │None                    │
+│       Number of Cases│                       0│
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬────────────────────────╮
+│Label    │PSPP synthetic test file│
+│Variables│                      12│
+╰─────────┴────────────────────────╯
+
+╭─┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│ │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├─┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│a│       1│     │Nominal          │Input│    1│Left     │F8.0        │F8.0        │              │
+│b│       2│     │Ordinal          │Input│    2│Left     │F8.0        │F8.0        │              │
+│c│       3│     │Scale            │Input│    3│Left     │F8.0        │F8.0        │              │
+│d│       4│     │Nominal          │Input│    4│Right    │F8.0        │F8.0        │              │
+│h│       5│     │Ordinal          │Input│    5│Right    │A3          │A3          │              │
+│i│       6│     │Scale            │Input│    6│Right    │A3          │A3          │              │
+│j│       7│     │Nominal          │Input│    7│Center   │A3          │A3          │              │
+│k│       8│     │Ordinal          │Input│    8│Center   │A3          │A3          │              │
+│l│       9│     │Scale            │Input│    9│Center   │A9          │A9          │              │
+│m│      10│     │Nominal          │Input│   10│Left     │A10         │A10         │              │
+│n│      11│     │Nominal          │Input│   11│Right    │A17         │A17         │              │
+│o│      12│     │Nominal          │Input│   12│Center   │A25         │A25         │              │
+╰─┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
diff --git a/rust/pspp/src/sys/testdata/variable_display_with_width.sack b/rust/pspp/src/sys/testdata/variable_display_with_width.sack
new file mode 100644 (file)
index 0000000..d23f75c
--- /dev/null
@@ -0,0 +1,53 @@
+# File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; # Layout code
+19; # Nominal case size
+0; # Not compressed
+0; # Not weighted
+0; # No cases.
+100.0; # Bias.
+"01 Jan 11"; "20:53:52"; s64 "PSPP synthetic 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";
+
+# Short string variables.
+2; 3; 0; 0; 0x010300 *2; s8 "H";
+2; 3; 0; 0; 0x010300 *2; s8 "I";
+2; 3; 0; 0; 0x010300 *2; s8 "J";
+2; 3; 0; 0; 0x010300 *2; s8 "K";
+
+# Long string variables.
+2; 9; 0; 0; 0x010900 *2; s8 "L";
+2; -1; 0; 0; 0; 0; s8 "";
+2; 10; 0; 0; 0x010a00 *2; s8 "M";
+2; -1; 0; 0; 0; 0; s8 "";
+2; 17; 0; 0; 0x011100 *2; s8 "N";
+( 2; -1; 0; 0; 0; 0; s8 "" ) * 2;
+2; 25; 0; 0; 0x011900 *2; s8 "O";
+( 2; -1; 0; 0; 0; 0; s8 "" ) * 3;
+
+# Variable display parameters
+7; 11; 4; 36;
+1; 1; 0;
+2; 2; 0;
+3; 3; 0;
+1; 4; 1;
+2; 5; 1;
+3; 6; 1;
+1; 7; 2;
+2; 8; 2;
+3; 9; 2;
+0; 10; 0;
+0; 11; 1;
+0; 12; 2;
+
+# Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+# Dictionary termination record.
+999; 0;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..97aa90c9ea60729e07468eae10b269d89059df73 100644 (file)
@@ -0,0 +1,30 @@
+╭──────────────────────┬────────────────────────╮
+│       Created        │    01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product        │PSPP synthetic test file│
+├──────────────────────┼────────────────────────┤
+│       Compression    │None                    │
+│       Number of Cases│                       0│
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬────────────────────────╮
+│Label    │PSPP synthetic test file│
+│Variables│                      12│
+╰─────────┴────────────────────────╯
+
+╭─┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│ │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├─┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│a│       1│     │Nominal          │Input│    8│Left     │F8.0        │F8.0        │              │
+│b│       2│     │Ordinal          │Input│    8│Left     │F8.0        │F8.0        │              │
+│c│       3│     │Scale            │Input│    8│Left     │F8.0        │F8.0        │              │
+│d│       4│     │Nominal          │Input│    8│Right    │F8.0        │F8.0        │              │
+│h│       5│     │Ordinal          │Input│    3│Right    │A3          │A3          │              │
+│i│       6│     │Scale            │Input│    3│Right    │A3          │A3          │              │
+│j│       7│     │Nominal          │Input│    3│Center   │A3          │A3          │              │
+│k│       8│     │Ordinal          │Input│    3│Center   │A3          │A3          │              │
+│l│       9│     │Scale            │Input│    9│Center   │A9          │A9          │              │
+│m│      10│     │Nominal          │Input│   10│Left     │A10         │A10         │              │
+│n│      11│     │Nominal          │Input│   17│Right    │A17         │A17         │              │
+│o│      12│     │Nominal          │Input│   25│Center   │A25         │A25         │              │
+╰─┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯