예제 #1
0
TEST_F (MamaPriceTestC, testGetValueMamaPrice)
{

   double x = 100,
          val;

   mama_price_hints_t hint = MAMA_PRICE_IMPL_HINT_PREC_10; 

   mamaPrice price     = CreateTestPrice(x,hint),
             nullPrice = NULL;

   EXPECT_EQ ( MAMA_STATUS_INVALID_ARG, mamaPrice_getValue(nullPrice, &val) );
   EXPECT_EQ ( MAMA_STATUS_INVALID_ARG, mamaPrice_getValue(price, NULL) );

   EXPECT_EQ ( MAMA_STATUS_OK, mamaPrice_getValue(price, &val) );
   EXPECT_EQ ( val, x);

   EXPECT_EQ ( MAMA_STATUS_OK, mamaPrice_destroy(price) );
}
예제 #2
0
mama_status
avisMsg_setPrice(
    Attributes*         attributes,
    const char*         name,
    mama_fid_t          fid,
    const mamaPrice     value)
{
	mama_f64_t tempF64;
	mamaPrice_getValue(value, &tempF64);
    return avisMsg_setF64(attributes,name,fid,tempF64);
}
예제 #3
0
/*  Description:     Use the price API to set the value of a price object
 *                   Upon successful completion, the fuction will set the value attribute of the price
 *                   object to the input value.
 *
 *  Expected Failures : NULL Price - MAMA STATUS INVALID ARG
 *
 *  Expected Passes   : With a valid price and value, the function retuns MAMA STATUS OK and updates
 *                    : the value attribute of the price to the new value
 *                                            
 */
TEST_F (MamaPriceTestC, testSetValueMamaPrice)
{

   double x = 100, 
          y = 200;

   mama_price_hints_t hints = MAMA_PRICE_IMPL_HINT_PREC_10; 

   mamaPrice price     = CreateTestPrice(x,hints), 
             nullPrice = NULL;

   EXPECT_EQ ( MAMA_STATUS_INVALID_ARG, mamaPrice_setValue(nullPrice, x) );

   EXPECT_EQ ( MAMA_STATUS_OK, mamaPrice_setValue(price, y) );
   EXPECT_EQ ( MAMA_STATUS_OK, mamaPrice_getValue(price, &x) );
   EXPECT_EQ ( x, y );

   EXPECT_EQ ( MAMA_STATUS_OK, mamaPrice_destroy(price) );
}
예제 #4
0
/*  Description:     Create a mamaPrice (m_price) of precision div128, get the
 *                   value of m_price as a double, format the double as a string
 *                   with an int flag (doubleString). Compare this to the string
 *                   representation of m_price(stringValue).
 *
 *  Expected Result: stringValue = doublestring = 4000000000
 */
TEST_F (MamaPriceTestC, SetPrecisionDiv128)
{
    double doubleValue      = 0;
    char   doubleString[20] = "";
    char   stringValue[20]  = "";
    /* Set the precision */
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPrice_setPrecision (m_price, MAMA_PRICE_PREC_DIV_128));
    
    /* Get the value as a double */
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPrice_getValue (m_price, &doubleValue));

    /* Format the double value as a string using an integer flag */
    sprintf (doubleString, WMPRICE_LARGE_INT64_FORMAT_SPECIFIER, (long long int)doubleValue);

    /* Get the value as a string */
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPrice_getAsString (m_price, stringValue, 19));

    /* Compare the strings */
    ASSERT_STREQ (stringValue, doubleString);    
}