f8f07a0028350693517a3e297e60fb8649733d97
[pspp-builds.git] / tests / data / sys-file.at
1 AT_BANNER([system files])
2
3 # Test that system files can be read properly, even when the case_size
4 # header value is -1 (Some 3rd party products do this).
5 AT_SETUP([system files with -1 case_size])
6 AT_DATA([save.sps], [dnl
7 DATA LIST LIST NOTABLE /cont (A32) size pop count.
8 VAR LABEL
9     cont 'continents of the world'
10     size 'sq km'
11     pop 'population'
12     count 'number of countries'.
13 SAVE OUTFILE='cont.sav'.
14 BEGIN DATA.
15 Asia, 44579000, 3.7E+009, 44.00
16 Africa, 30065000, 7.8E+008, 53.00
17 "North America", 24256000, 4.8E+008, 23.00
18 "South America", 17819000, 3.4E+008, 12.00
19 Antarctica, 13209000, .00, .00
20 Europe, 9938000, 7.3E+008, 46.00
21 Australia/Oceania, 7687000, 31000000, 14.00
22 END DATA.
23 ])
24 AT_CHECK([pspp -O format=csv save.sps])
25 AT_CHECK([test -f cont.sav])
26
27 dnl case_size is a 4-byte field at offset 68.
28 dnl Make a new copy with its value changed to -1.
29 AT_CHECK(
30   [(dd if=cont.sav bs=1 count=68;
31     printf '\377\377\377\377';
32     dd if=cont.sav bs=1 skip=72) > cont2.sav], [0], [], [ignore])
33 AT_CHECK([cmp cont.sav cont2.sav], [1],
34   [cont.sav cont2.sav differ: char 69, line 1
35 ])
36
37 AT_DATA([get.sps], [dnl
38 GET FILE='cont2.sav'.
39 DISPLAY LABELS.
40 LIST.
41 ])
42 AT_CHECK([pspp -o pspp.csv get.sps])
43 AT_CHECK([cat pspp.csv], [0], [dnl
44 Variable,Label,,Position
45 cont,continents of the world,,1
46 size,sq km,,2
47 pop,population,,3
48 count,number of countries,,4
49
50 Table: Data List
51 cont,size,pop,count
52 Asia                            ,44579000,3.7E+009,44.00
53 Africa                          ,30065000,7.8E+008,53.00
54 North America                   ,24256000,4.8E+008,23.00
55 South America                   ,17819000,3.4E+008,12.00
56 Antarctica                      ,13209000,.00,.00
57 Europe                          ,9938000,7.3E+008,46.00
58 Australia/Oceania               ,7687000,31000000,14.00
59 ])
60 AT_CLEANUP