Description
The behavior of CSV2GDX is tested when specifying incorrect parameter input. Contributor Jan-Erik Justkowiak, May 2018
Small Model of Type : GAMS
Category : GAMS Test library
Main file : csv2gdx7.gms
$title CSV2GDX - Checking the Error Messages for incorrect Parameter Input (CSV2GDX7,SEQ=752)
$onText
The behavior of CSV2GDX is tested when specifying incorrect parameter input.
Contributor Jan-Erik Justkowiak, May 2018
$offText
$onEcho > data.csv
,a,b,c,d,e,f,g
I,1,2,3,4,5,6,7.2
$offEcho
* Check for duplicate options! (Note: The error message is triggered no matter
* whether the parameter specifications are inconsinstent or not!
$log 1. Duplicate ID
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol id=x trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 1. Error expected: Duplicate option: ID!
$log
$log 2. Duplicate useHeader
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol useHeader=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 2. Error expected: Duplicate option: useHeader!
$log
$log 3. Duplicate values
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol values=1..lastCol trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 3. Error expected: Duplicate option: value(s)!
$log
$log 4. Duplicate value
$call csv2gdx data.csv id=x index=1 useHeader=y value=2 value=2 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 4. Error expected: Duplicate option: value!
$log
$log 5. Duplicate index
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol index=1 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 5. Error expected: Duplicate option: index!
$log
$log 6. Duplicate output
$call csv2gdx data.csv output=temp.gdx id=x index=1 useHeader=y values=2..lastCol output=temp.gdx trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 6. Error expected: Duplicate option: output!
$log
$log 7. Duplicate storeZero
$call csv2gdx data.csv id=x index=1 useHeader=y storeZero=y values=2..lastCol storeZero=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 7. Error expected: Duplicate option: storeZero!
$log
$log 8. Duplicate valueDim
$call csv2gdx data.csv id=x index=1 useHeader=y valueDim=y value=2 valueDim=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 8. Error expected: Duplicate option: valueDim!
$log
$log 9. Duplicate colCount
$call csv2gdx data.csv id=x index=1 useHeader=y colCount=7 values=2..lastCol colCount=7 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 9. Error expected: Duplicate option: colCount!
$log
$log 10. Duplicate checkDate
$call csv2gdx data.csv id=x index=1 useHeader=y checkDate=y values=2..lastCol checkDate=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 10. Error expected: Duplicate option: checkDate!
$log
$log 11. Duplicate autoRow
$call csv2gdx data.csv id=x index=1 useHeader=y autoRow=r values=2..lastCol autoRow=r trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 11. Error expected: Duplicate option: autoRow!
$log
$log 12. Duplicate autoCol
$call csv2gdx data.csv id=x index=1 useHeader=y autoCol=c values=2..8 colCount=8 autoCol=c trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 12. Error expected: Duplicate option: autoCol!
$log
$log 13. Duplicate fieldSep
$call csv2gdx data.csv id=x index=1 useHeader=y fieldSep=comma values=2..lastCol fieldSep=comma trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 13. Error expected: Duplicate option: fieldSep!
$log
$log 14. Duplicate decimalSeparator
$call csv2gdx data.csv id=x index=1 useHeader=y decimalSeparator=period values=2..lastCol decimalSeparator=period trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 14. Error expected: Duplicate option: decimalSeparator!
$log
$log 15. Duplicate password
$call csv2gdx data.csv id=x index=1 useHeader=y password=123 values=2..lastCol password=123 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 15. Error expected: Duplicate option: password!
$log
*-------------------------------------------------------------------------------
* We want to read the values of column 2 and 4-7 by using the value and values option
* This will fail
$log 16. Value und values Option
$call csv2gdx data.csv id=x index=1 useHeader=y value=2 values=4..7 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 16. Error expected: Duplicate option: Value!
$log
* Each column must be specified within the values option
* This will succeed
$log 17.
$call csv2gdx data.csv id=x index=1 useHeader=y values=2,4..7 trace=0
$ifE errorLevel<>0 $abort Error: CSV2GDX should have succeeded after running 17.!
$log
*-------------------------------------------------------------------------------
* Calculations with the lastCol constant are not allowed
$log 18. Calculations with the lastCol constant
$call csv2gdx data.csv id=x index=1 useHeader=y values=lastCol-1 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 18. Error expected: Error in parameter value: Unexpected character!
$log
*-------------------------------------------------------------------------------
* Checking the error messages if fieldSep, decimalSeparator, useHeader, storeZero,
* valueDim or checkDate is set to an unknown value
$log 19. Incorrect fieldSep
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol fieldSep=coma trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 19. Error expected: Unknown value for fieldSep option = COMA!
$log
$log 20. Incorrect decimalSeparator
$call csv2gdx data.csv id=x index=1 useHeader=y values=2..lastCol decimalSeparator=coma trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 20. Error expected: Unknown value for decimalSeparator option = COMA!
$log
$log 21. Incorrect useHeader
$call csv2gdx data.csv id=x index=1 useHeader=ye values=2..lastCol trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 21. Error expected: Bad flag value!
$log
$log 22. Incorrect storeZero
$call csv2gdx data.csv id=x index=1 useHeader=y storeZero=ye values=2..lastCol trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 22. Error expected: Bad flag value!
$log
$log 23. Incorrect valueDim
$call csv2gdx data.csv id=x index=1 useHeader=y valueDim=ye values=2..lastCol trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 23. Error expected: Bad flag value!
$log
$log 24. Incorrect checkDate
$call csv2gdx data.csv id=x index=1 useHeader=y checkDate=ye values=2..lastCol trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 24. Error expected: Bad flag value!
$log
*-------------------------------------------------------------------------------
* Check the messages if the column in value(s) or index option does not exists
$log 25. Incorrect value input - Bad column number
$call csv2gdx data.csv id=x index=1 useHeader=y value=0 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 25. Error expected: Error in parameter Value: Bad column number specification!
$log
$log 26. Incorrect values input - Bad column number
$call csv2gdx data.csv id=x index=1 useHeader=y values=0,5,6 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 26. Error expected: Error in parameter Value: Bad column number specification!
$log
$log 27. Incorrect index input - Bad column number
$call csv2gdx data.csv id=x index=0 useHeader=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 27. Error expected: Error in parameter Index: Bad column number specification!
$log
$log 28. Incorrect value input - Exceeding column count
$call csv2gdx data.csv id=x index=1 useHeader=y value=10 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 28. Error expected: Value(s) column number exceeds column count!
$log
$log 29. Incorrect values input - Exceeding column count
$call csv2gdx data.csv id=x index=1 useHeader=y values=5,6,10 trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 29. Error expected: Value(s) column number exceeds column count!
$log
$log 30. Incorrect index input - Exceeding column count
$call csv2gdx data.csv id=x index=10 useHeader=y trace=0
$ifE errorLevel=0 $abort CSV2GDX should have failed after running 30. Error expected: Index column number exceeds column count!
$log
*-------------------------------------------------------------------------------