DISPLAY DICTIONARY: Add "Label: " prefix for variable labels in output.
[pspp] / tests / data / sys-file.at
index c321180a72d8f9ddf7ff523a4890c6bf654d0caf..033a7da9af414433bffaeb970c8ce8263e7f3a59 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,67 @@ 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,,1
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 9,,
+,"Missing Values: ""0       """,,
+,abc      ,First value label,
+,abcdefgh ,Second value label,
+,abcdefghi,Third value label,
+s2,Format: A9,,2
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 9,,
+,"Missing Values: ""12      ""; ""123     """,,
+,0        ,Fourth value label,
+,01234567 ,Fifth value label,
+,012345678,Sixth value label,
+s3,Format: A9,,3
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 9,,
+,"Missing Values: ""1234    ""; ""12345   ""; ""12345678""",,
+])
+    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])
@@ -55,14 +119,13 @@ GET FILE='com.sav'.
 LIST.
 ])
 AT_CHECK([pspp -o pspp.csv sysfile.sps])
-dnl Make sure file really was compressd.
-AT_CHECK([dd if=com.sav bs=1 skip=72 count=4 2> /dev/null | od | sed '1q' > com.txt])
-dnl Allow big- or little-endian format.
+dnl Make sure file really was compressd, allowing big- or little-endian format.
+AT_CHECK([dd if=com.sav bs=1 skip=72 count=4 2> /dev/null > com.sav.subset])
+od com.sav.subset
 AT_CHECK(
-  [(echo '0000000 000000 000001' | diff com.txt -) ||
-   (echo '0000000 000001 000000' | diff com.txt -)], [0],
+  [(printf '\000\000\000\001' | cmp -l com.sav.subset -) ||
+   (printf '\001\000\000\000' | cmp -l com.sav.subset -)], [0],
   [ignore])
-AT_CAPTURE_FILE([com.txt])
 AT_CLEANUP
 
 AT_SETUP([overwriting system file])
@@ -125,7 +188,7 @@ LIST.
 ])
 AT_CHECK([pspp -O format=csv save3.sps], [0], [dnl
 Table: Data List
-X,Y
+x,y
 3,9.00
 ])
 AT_CLEANUP
@@ -380,3 +443,78 @@ d,Format: A32767,,4
 
 VLS_WRITE([UNCOMPRESSED])
 VLS_WRITE([COMPRESSED])
+
+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([i18n-test supports_encodings windows-1252])
+AT_DATA([save.sps], [dnl
+SET LOCALE='windows-1252'.
+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
+      /àéîöç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=àéîöçxyzabc
+      ATTRIBUTE=Atatürk('Düsseldorf Gewürztraminer').
+BEGIN DATA.
+1 a x
+2 b y
+3 c z
+END DATA.
+SAVE OUTFILE='foo.sav'.
+])
+AT_CHECK([pspp -O format=csv save.sps])
+AT_DATA([get.sps], [dnl
+GET FILE='foo.sav'.
+DISPLAY FILE LABEL.
+DISPLAY DOCUMENTS.
+DISPLAY DICTIONARY.
+])
+AT_CHECK([pspp -o pspp.csv get.sps])
+AT_CHECK([[sed 's/(Entered [^)]*)/(Entered <date>)/' pspp.csv]], [0], [dnl
+File label: clientèle confrère cortège crèche
+
+Documents in the active dataset:
+
+DOCUMENT coördinate smörgåsbord
+
+épée séance soufflé soirée
+
+jalapeño vicuña.
+
+(Entered <date>)
+
+Variable,Description,,Position
+àéîöçxyzabc,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é,Label: 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,,
+
+Table: Custom data file attributes.
+Attribute,Value
+Furtwängler,kindergärtner
+])
+AT_CLEANUP