From 8879f6fc1caf572cbe0d22ef41798cfb4d0c49bb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 8 Jun 2025 12:51:00 -0700 Subject: [PATCH] more variable display --- rust/pspp/src/sys/test.rs | 5 ++ .../variable_display_with_width.expected | 30 +++++++++++ .../testdata/variable_display_with_width.sack | 53 +++++++++++++++++++ .../variable_display_without_width.expected | 30 +++++++++++ 4 files changed, 118 insertions(+) create mode 100644 rust/pspp/src/sys/testdata/variable_display_with_width.expected create mode 100644 rust/pspp/src/sys/testdata/variable_display_with_width.sack diff --git a/rust/pspp/src/sys/test.rs b/rust/pspp/src/sys/test.rs index 3265db5c48..eb51ecf126 100644 --- a/rust/pspp/src/sys/test.rs +++ b/rust/pspp/src/sys/test.rs @@ -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 index 0000000000..a90f718cbf --- /dev/null +++ b/rust/pspp/src/sys/testdata/variable_display_with_width.expected @@ -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 index 0000000000..d23f75cc42 --- /dev/null +++ b/rust/pspp/src/sys/testdata/variable_display_with_width.sack @@ -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; diff --git a/rust/pspp/src/sys/testdata/variable_display_without_width.expected b/rust/pspp/src/sys/testdata/variable_display_without_width.expected index e69de29bb2..97aa90c9ea 100644 --- a/rust/pspp/src/sys/testdata/variable_display_without_width.expected +++ b/rust/pspp/src/sys/testdata/variable_display_without_width.expected @@ -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 │ │ +╰─┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯ -- 2.30.2