X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fdata-io%2Fsave-translate.at;h=d2dd858059fffd74d2b676fe9b7ab4fe95d0bb92;hb=ce4541a84961ad1e4fa814ece374360a79044bf7;hp=89561f8740e478cd9e42dd602c24695525bbb950;hpb=691a034d7f2139076fa012739dffd40ef5db4a9b;p=pspp diff --git a/tests/language/data-io/save-translate.at b/tests/language/data-io/save-translate.at index 89561f8740..d2dd858059 100644 --- a/tests/language/data-io/save-translate.at +++ b/tests/language/data-io/save-translate.at @@ -1,19 +1,20 @@ dnl PSPP - a program for statistical analysis. dnl Copyright (C) 2017 Free Software Foundation, Inc. -dnl +dnl dnl This program is free software: you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation, either version 3 of the License, or dnl (at your option) any later version. -dnl +dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. -dnl +dnl dnl You should have received a copy of the GNU General Public License dnl along with this program. If not, see . -dnl AT_BANNER([SAVE TRANSLATE /TYPE=CSV]) +dnl +AT_BANNER([SAVE TRANSLATE /TYPE=CSV]) m4_define([PREPARE_SAVE_TRANSLATE_CSV], [dnl AT_KEYWORDS([SAVE TRANSLATE]) @@ -84,16 +85,66 @@ number:time:date:datetime:string:filter ]) AT_CLEANUP -AT_SETUP([CSV output -- KEEP, RENAME]) +AT_SETUP([CSV output -- KEEP, RENAME quoted]) PREPARE_SAVE_TRANSLATE_CSV( - [/FIELDNAMES /KEEP=time string /RENAME string=name /UNSELECTED=DELETE]) + [/FIELDNAMES /KEEP=time string /RENAME string='long name with spaces' /UNSELECTED=DELETE]) AT_CHECK([cat data.csv], [0], [dnl -time,name +time,long name with spaces -05:17:00, xxx 12:00:00,xyzzy ]) AT_CLEANUP + +AT_SETUP([CSV output -- KEEP, RENAME multi quoted]) +PREPARE_SAVE_TRANSLATE_CSV( + [/FIELDNAMES + /RENAME = + number = "this one" + time = "that one" + date = "which one?" + datetime = "another variable replacement" + string="long name with spaces" + /UNSELECTED=DELETE]) +AT_CHECK([cat data.csv], [0], [dnl +this one,that one,which one?,another variable replacement,long name with spaces,filter + ,-05:17:00,10/31/2010,04/09/2008 09:29:00, xxx,1 +1.625,12:00:00, , ,xyzzy,1 +]) +AT_CLEANUP + + +AT_SETUP([CSV output -- KEEP, RENAME bad name ]) +AT_DATA([bad.sps], [ +data list notable list /Var1 Var2 Var3 Var4 Var5 *. +begin data +1 2 3 4 5 +end data. + +SAVE TRANSLATE +/OUTFILE="foo.csv" + /TYPE=CSV + /MAP + /REPLACE + /FIELDNAMES + /Unselected=DELETE + /RENAME = + Var4 = foobar + (Var1 Var2 = one Var3 ) + (Var3 = "The second") + /CELLS=VALUES +. +]) + +AT_CHECK([pspp -O format=csv bad.sps], [1], [dnl +"bad.sps:16: error: SAVE TRANSLATE: Cannot rename Var2 as Var3 because there already exists a variable named Var3. To rename variables with overlapping names, use a single RENAME subcommand such as `/RENAME (A=B)(B=C)(C=A)', or equivalently, `/RENAME (A B C=B C A)'." +]) + + +AT_CLEANUP + + + AT_BANNER([SAVE TRANSLATE /TYPE=TAB]) AT_SETUP([TAB output]) @@ -105,3 +156,4 @@ number time date datetime string filter 1.625 12:00:00 xyzzy 1 ]) AT_CLEANUP +