SYSFILE INFO: Improve output formatting by using nested tables.
[pspp] / tests / data / sys-file.at
index a2980853e1224e4cbde2bb36580add60d70fa3a0..3e1fbb1fac91449fe193115cba107024d3566e5e 100644 (file)
@@ -3,7 +3,10 @@ AT_BANNER([system files])
 # Also tests that long variable names are preserved by SAVE and GET.
 AT_SETUP([write and read numeric data])
 AT_KEYWORDS([SAVE GET system file])
-AT_DATA([sysfile.sps], [dnl
+for variant in 'UNCOMPRESSED $FL2' 'ZCOMPRESSED $FL3'; do
+    set $variant
+    compression=$1 magic=$2
+    cat >sysfile.sps <<EOF
 DATA LIST LIST NOTABLE / variable001 * variable002 * variable003 * variable004 * .
 BEGIN DATA.
     1.00     1.00    1.0     2.00
@@ -16,14 +19,14 @@ BEGIN DATA.
     2.00     2.00    2.0     3.00
 END DATA.
 
-SAVE /OUTFILE='foo.sav'.
+SAVE/$compression /OUTFILE='foo.sav'.
 
 GET /FILE='foo.sav'.
 
 LIST.
-])
-AT_CHECK([pspp -o pspp.csv sysfile.sps])
-AT_CHECK([cat pspp.csv], [0], [dnl
+EOF
+    AT_CHECK([pspp -o pspp.csv sysfile.sps])
+    AT_CHECK([cat pspp.csv], [0], [dnl
 Table: Data List
 variable001,variable002,variable003,variable004
 1.00,1.00,1.00,2.00
@@ -35,6 +38,62 @@ variable001,variable002,variable003,variable004
 2.00,2.00,1.00,1.00
 2.00,2.00,2.00,3.00
 ])
+    AT_CHECK_UNQUOTED([dd if=foo.sav bs=1 count=4; echo], [0], [$magic
+], [ignore])
+done
+AT_CLEANUP
+
+AT_SETUP([write and read long string value labels and missing values])
+AT_KEYWORDS([SAVE GET system file])
+for variant in 'UNCOMPRESSED $FL2' 'ZCOMPRESSED $FL3'; do
+    set $variant
+    compression=$1 magic=$2
+    cat >sysfile.sps <<EOF
+DATA LIST LIST NOTABLE/s1 s2 s3 (a9).
+BEGIN DATA
+a b c
+END DATA.
+
+VALUE LABELS
+    /s1 'abc' 'First value label'
+       'abcdefgh' 'Second value label'
+       'abcdefghi' 'Third value label'
+    /s2 '0' 'Fourth value label'
+       '01234567' 'Fifth value label'
+       '012345678' 'Sixth value label'.
+
+MISSING VALUES
+     s1 ('0')
+    /s2 ('12' '123')
+    /s3 ('1234' '12345' '12345678').
+
+SAVE/$compression /OUTFILE='foo.sav'.
+GET /FILE='foo.sav'.
+DISPLAY DICTIONARY.
+EOF
+    AT_CHECK([pspp -o pspp.csv sysfile.sps])
+    AT_CHECK([cat pspp.csv], [0], [dnl
+Variable,Description,Position
+s1,"Format: A9
+Missing Values: ""0       ""
+
+Value,Label
+abc      ,First value label
+abcdefgh ,Second value label
+abcdefghi,Third value label",1
+s2,"Format: A9
+Missing Values: ""12      ""; ""123     ""
+
+Value,Label
+0        ,Fourth value label
+01234567 ,Fifth value label
+012345678,Sixth value label",2
+s3,"Format: A9
+Missing Values: ""1234    ""; ""12345   ""; ""12345678""",3
+])
+    AT_CHECK_UNQUOTED([dd if=foo.sav bs=1 count=4; echo], [0], [$magic
+], [ignore])
+done
 AT_CLEANUP
 
 AT_SETUP([write and read compressed files])
@@ -195,11 +254,11 @@ LIST.
 ])
 AT_CHECK([pspp -o pspp.csv get.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
-Variable,Label,,Position
-cont,continents of the world,,1
-size,sq km,,2
-pop,population,,3
-count,number of countries,,4
+Variable,Label,Position
+cont,continents of the world,1
+size,sq km,2
+pop,population,3
+count,number of countries,4
 
 Table: Data List
 cont,size,pop,count
@@ -257,29 +316,21 @@ AT_BANNER([system files -- very long strings])
 AT_SETUP([read very long strings written by SPSS 13])
 AT_CHECK([cp $top_srcdir/tests/data/v13.sav .])
 AT_DATA([sys-file.sps], [dnl
-GET FILE='v13.sav'.
+GET FILE='v13.sav' ENCODING='utf-8'.
 DISPLAY VARIABLES.
 LIST.
 ])
 AT_CHECK([pspp -o pspp.csv sys-file.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
-Variable,Description,,Position
-N,Format: F8.2,,1
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 10,,
-A255,Format: A255,,2
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
-A258,Format: A258,,3
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
-A2000,Format: A2000,,4
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
+Variable,Description,Position
+N,"Format: F8.2
+Display Width: 10",1
+A255,"Format: A255
+Display Width: 32",2
+A258,"Format: A258
+Display Width: 32",3
+A2000,"Format: A2000
+Display Width: 32",4
 
 Table: Data List
 N,A255,A258,A2000
@@ -291,29 +342,21 @@ AT_CLEANUP
 AT_SETUP([read very long strings written by SPSS 14])
 AT_CHECK([cp $top_srcdir/tests/data/v14.sav .])
 AT_DATA([sys-file.sps], [dnl
-GET FILE='v14.sav'.
+GET FILE='v14.sav' ENCODING='utf-8'.
 DISPLAY VARIABLES.
 LIST.
 ])
 AT_CHECK([pspp -o pspp.csv sys-file.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
-Variable,Description,,Position
-vl255,Format: A255,,1
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 26,,
-vl256,Format: A256,,2
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 26,,
-vl1335,Format: A1335,,3
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 26,,
-vl2000,Format: A2000,,4
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 26,,
+Variable,Description,Position
+vl255,"Format: A255
+Display Width: 26",1
+vl256,"Format: A256
+Display Width: 26",2
+vl1335,"Format: A1335
+Display Width: 26",3
+vl2000,"Format: A2000
+Display Width: 26",4
 
 Table: Data List
 vl255,vl256,vl1335,vl2000
@@ -357,23 +400,11 @@ EXECUTE.
 ])
    AT_CHECK([pspp -o pspp.csv get.sps])
    AT_CHECK([cat pspp.csv], [0], [dnl
-Variable,Description,,Position
-a,Format: A10,,1
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 10,,
-b,Format: A256,,2
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
-c,Format: A200,,3
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
-d,Format: A32767,,4
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
+Variable,Description,Position
+a,Format: A10,1
+b,Format: A256,2
+c,Format: A200,3
+d,Format: A32767,4
 ])
    AT_CLEANUP])
 
@@ -384,23 +415,23 @@ dnl This test writes non-ASCII characters to most of the string fields in
 dnl a .sav file and demonstrates that they are properly read back in.
 dnl XXX mrsets tests are missing.
 AT_SETUP([system file character encoding])
-AT_CHECK([supports_encodings windows-1252])
+AT_CHECK([i18n-test supports_encodings windows-1252])
 AT_DATA([save.sps], [dnl
 SET LOCALE='windows-1252'.
-DATA LIST LIST NOTABLE /àéîöç * roué (A9) croûton (A1000).
+DATA LIST LIST NOTABLE /àéîöçxyzabc * roué (A9) croûton (A1000).
 FILE LABEL 'clientèle confrère cortège crèche'.
 DOCUMENT coördinate smörgåsbord
 épée séance soufflé soirée
 jalapeño vicuña.
 VALUE LABEL
-      /àéîöç 1 'éclair élan'
+      /àéîöçxyzabc 1 'éclair élan'
       /roué 'abcdefghi' 'sauté précis'.
 VARIABLE LABEL
       roué 'Provençal soupçon'.
 DATAFILE ATTRIBUTE
       ATTRIBUTE=Furtwängler('kindergärtner').
 VARIABLE ATTRIBUTE
-      VARIABLES=àéîöç
+      VARIABLES=àéîöçxyzabc
       ATTRIBUTE=Atatürk('Düsseldorf Gewürztraminer').
 BEGIN DATA.
 1 a x
@@ -430,24 +461,20 @@ jalapeño vicuña.
 
 (Entered <date>)
 
-Variable,Description,,Position
-àéîöç,Format: F8.2,,1
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-,1.00,éclair élan,
-,Custom attributes:,,
-,Atatürk,Düsseldorf Gewürztraminer,
-roué,Provençal soupçon,,2
-,Format: A9,,
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 9,,
-,abcdefghi,sauté précis,
-croûton,Format: A1000,,3
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 32,,
+Variable,Description,Position
+àéîöçxyzabc,"Format: F8.2
+
+Value,Label
+1.00,éclair élan
+
+Attribute,Value
+Atatürk,Düsseldorf Gewürztraminer",1
+roué,"Label: Provençal soupçon
+Format: A9
+
+Value,Label
+abcdefghi,sauté précis",2
+croûton,Format: A1000,3
 
 Table: Custom data file attributes.
 Attribute,Value