Changeset 573


Ignore:
Timestamp:
07/16/14 03:57:22 (5 years ago)
Author:
jls17
Message:
  • added support for none-functional currency-field references within text
Location:
branches/work_311/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/work_311/core/ARParseField.cpp

    r570 r573  
    5050                if (result == FINISHED) 
    5151                { 
     52                        if (typeId >= AR_CURRENCY_PART_VALUE && typeId <= AR_CURRENCY_PART_DATE) 
     53                        { 
     54                                SetupCurrencyField(fieldId, typeId); 
     55                                return; 
     56                        } 
     57 
    5258                        result = FAILED; 
    5359                        return; 
     
    166172void CARParseField::SetupCurrencyField(int fieldId, int currencyPart, char* currencyCode) 
    167173{ 
    168         if (!IsValidCurrencyPart(currencyPart) || currencyCode == NULL) 
     174        if (!IsValidCurrencyPart(currencyPart)) 
    169175                return; 
    170176 
     
    173179        field.u.currencyField->fieldId = fieldId; 
    174180        field.u.currencyField->partTag = currencyPart; 
    175         strncpy(field.u.currencyField->currencyCode, currencyCode, AR_MAX_CURRENCY_CODE_SIZE + 1); 
     181 
     182        if (currencyCode == NULL) 
     183        { 
     184                ARZeroMemory(&field.u.currencyField->currencyCode); 
     185        } 
     186        else 
     187        { 
     188                strncpy(field.u.currencyField->currencyCode, currencyCode, AR_MAX_CURRENCY_CODE_SIZE + 1); 
     189        } 
    176190} 
    177191 
  • branches/work_311/core/ARParseField.h

    r570 r573  
    5555        void SetupField(int fieldId); 
    5656        void SetupStatusHistory(int fieldId, int usrOrTime, int enumId); 
    57         void SetupCurrencyField(int fieldId, int currencyPart, char* currencyCode); 
     57        void SetupCurrencyField(int fieldId, int currencyPart, char* currencyCode = NULL); 
    5858}; 
  • branches/work_311/core/ARParseFieldTest.cpp

    r569 r573  
    2020                field.u.currencyField->partTag == currencyPartType && 
    2121                strcmp(field.u.currencyField->currencyCode, partCode) == 0); 
     22} 
     23 
     24bool isCurrencyField(const ARParseField& field, int fieldId, int currencyPartType) 
     25{ 
     26        return (field.tag == AR_CURRENCY_FLD && 
     27                field.u.currencyField->fieldId == fieldId && 
     28                field.u.currencyField->partTag == currencyPartType && 
     29                field.u.currencyField->partTag != AR_CURRENCY_PART_FUNCTIONAL && 
     30                strcmp(field.u.currencyField->currencyCode, "") == 0); 
    2231} 
    2332 
     
    7887} 
    7988 
    80 TEST(ARParseFieldTests, CurrencyField) 
     89TEST(ARParseFieldTests, CurrencyFieldFunctional) 
    8190{ 
    8291        CARParseField parseField("536870987.1.USD"); 
    8392        const ARParseField &result = parseField.getField(); 
    8493 
    85         ASSERT_TRUE(isCurrencyField(result, 536870987, 1, "USD")); 
     94        ASSERT_TRUE(isCurrencyField(result, 536870987, AR_CURRENCY_PART_VALUE, "USD")); 
    8695} 
     96 
     97TEST(ARParseFieldTests, CurrencyFieldSimple) 
     98{ 
     99        CARParseField parseField("536870987.3"); 
     100        const ARParseField &result = parseField.getField(); 
     101 
     102        ASSERT_TRUE(isCurrencyField(result, 536870987, AR_CURRENCY_PART_DATE)); 
     103} 
Note: See TracChangeset for help on using the changeset viewer.