diff --git a/centrallix/osdrivers/objdrv_fp.c b/centrallix/osdrivers/objdrv_fp.c index 452a3100..3d35e52f 100644 --- a/centrallix/osdrivers/objdrv_fp.c +++ b/centrallix/osdrivers/objdrv_fp.c @@ -1223,37 +1223,14 @@ fp_internal_ParseColumn(pFpColInf column, pObjData pod, char* data, char* row_da int i,f; double decimalOffsetValue = 10000; + // Currently columns are only ever DATA_T_STRING since automatic type detection hasn't been implemented yet + // See fp_internal_ParseDefinition() switch(column->Type) { - case DATA_T_INTEGER: - if (fp_internal_MappedCopy(ibuf, sizeof(ibuf), column, row_data) < 0) return -1; - pod->Integer = strtoi(ibuf, NULL, 10); - break; case DATA_T_STRING: pod->String = data; if (fp_internal_MappedCopy(data, column->Length+1, column, row_data) < 0) return -1; break; - case DATA_T_DATETIME: - pod->DateTime = (pDateTime)data; - if (fp_internal_MappedCopy(dtbuf, sizeof(dtbuf), column, row_data) < 0) return -1; - if (objDataToDateTime(DATA_T_STRING, dtbuf, pod->DateTime, NULL) < 0) return -1; - break; - case DATA_T_DOUBLE: - if (fp_internal_MappedCopy(ibuf, sizeof(ibuf), column, row_data) < 0) return -1; - pod->Double = strtol(ibuf, NULL, 10); - if (column->DecimalOffset) pod->Double /= pow(10, column->DecimalOffset); - break; - case DATA_T_MONEY: - //decimalOffsetValue is originally 10000 to convert v to 10000ths of a dollar - //decimalOffsetValue is divided by 10, column->DecimalOffset times, - //keeping the decimal as a double in case it drops below 0 - //Finally, I multiple v by decimalOffsetValue to get my Money->Value - if (fp_internal_MappedCopy(ibuf, sizeof(ibuf), column, row_data) < 0) return -1; - v = strtoll(ibuf, NULL, 10); - decimalOffsetValue /= pow(10, column->DecimalOffset); - pod->Money = (pMoneyType)data; - pod->Money->Value = (v*decimalOffsetValue)+ 0.1; - break; default: mssError(1, "FP", "Bark! Unhandled data type for column '%s'", column->Name); return -1; diff --git a/centrallix/tests/test_moneytype_objdrv_fp.c b/centrallix/tests/test_moneytype_objdrv_fp.c deleted file mode 100644 index 73039fb9..00000000 --- a/centrallix/tests/test_moneytype_objdrv_fp.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "obj.h" -#include -#include -#include "expression.h" -#include "cxlib/xstring.h" -#include "osdrivers/objdrv_fp.c" - -long long -test(char** name) -{ - *name = "moneytype_00 - objdrv_fp"; - - //This test is making the assumption that the raw data passed in testString here (row_data in objdrv_fp.c) - //is in units of dollars (and so dbl_internal_ParseColumn should convert it to 1/10000ths of a dollar when putting - //it into a MoneyType representation) - - FpColInf testColInf; - pFpColInf pTestColInf = &testColInf; - - testColInf.Type = DATA_T_MONEY; - testColInf.Length = 8; - testColInf.RecordOffset = 0; - testColInf.DecimalOffset = 0; - ObjData moneyData; - pObjData moneyDataPtr = &moneyData; - MoneyType testMoneyData = {0}; - pMoneyType pTestMoneyData = &testMoneyData; - - /** No Decimal Offset Case **/ - char* rowData = "450"; - assert(fp_internal_ParseColumn(pTestColInf, moneyDataPtr, (char*)pTestMoneyData, rowData) == 0); - assert(moneyDataPtr->Money->Value == 4500000); - - /** Decimal Offset, multiplier > 1 case **/ - testColInf.DecimalOffset = 1; - assert(fp_internal_ParseColumn(pTestColInf, moneyDataPtr, (char*)pTestMoneyData, rowData) == 0); - assert(moneyDataPtr->Money->Value == 450000); - - /** Decimal Offset, multiplier < 1 case **/ - testColInf.DecimalOffset = 5; - assert(fp_internal_ParseColumn(pTestColInf, moneyDataPtr, (char*)pTestMoneyData, rowData) == 0); - assert(moneyDataPtr->Money->Value == 45); - - /** Rounding for floating point error handling **/ - char* testRoundedString = "45011999"; - testColInf.DecimalOffset = 5; - assert(fp_internal_ParseColumn(pTestColInf, moneyDataPtr, (char*)pTestMoneyData, testRoundedString) == 0); - assert(moneyDataPtr->Money->Value == 4501200); - - return 0; -}