Added tests for descriptives and flip
[pspp-builds.git] / tests / command / count.sh
1 #!/bin/sh
2
3 # This program tests the count transformation
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 cat > $TEMPDIR/count.stat <<EOF
49 title 'Test COUNT transformation'.
50
51 * we're going to count the 2s 4s and 1s in the data
52 data list /v1 to v2 1-4(a).
53 begin data.
54 1234
55 321      <----
56 2 13     <----
57 4121
58 1104     ---- this is not '4', but '04' (v1 and v2 are string format )
59 03 4     <----
60 0193
61 end data.
62 count c=v1 to v2('2',' 4','1').
63 list.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 $here/../src/pspp -o raw-ascii $TEMPDIR/count.stat
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71
72 activity="compare results"
73 diff -b -B $TEMPDIR/pspp.list - <<EOF
74 1.1 DATA LIST.  Reading 1 record from the command file.
75 +--------+------+-------+------+
76 |Variable|Record|Columns|Format|
77 #========#======#=======#======#
78 |V1      |     1|  1-  2|A2    |
79 |V2      |     1|  3-  4|A2    |
80 +--------+------+-------+------+
81
82 V1 V2        C
83 -- -- --------
84 12 34      .00 
85 32 1      1.00 
86 2  13     1.00 
87 41 21      .00 
88 11 04      .00 
89 03  4     1.00 
90 01 93      .00 
91 EOF
92 if [ $? -ne 0 ] ; then no_result ; fi
93
94
95 pass;