Esempio n. 1
0
/**** Local functions definitions.     ****/
static ErrorNumber test_with_simulator( void )
{
   ErrorNumber retValue;

   /* Initialize the library. */
   retValue = allocLib();
   if( retValue != TA_TEST_PASS )
      return retValue;

   /* Perform testing of each of the TA Functions. */
   retValue = testTAFunction_ALL();
   if( retValue != TA_TEST_PASS )
   {
      return retValue;
   }

   /* Clean-up and exit. */

   retValue = freeLib( );
   if( retValue != TA_TEST_PASS )
      return retValue;

   return TA_TEST_PASS; /* All test succeed. */
}
Esempio n. 2
0
/**** Local functions definitions.     ****/
static ErrorNumber test_with_simulator( void )
{
   TA_UDBase  *uDBase;
   TA_History *history;
   TA_AddDataSourceParam param;
   TA_RetCode  retCode;
   ErrorNumber retValue;
   TA_HistoryAllocParam histParam;

   /* Initialize the library. */
   retValue = allocLib( &uDBase );
   if( retValue != TA_TEST_PASS )
      return retValue;

   /* Add a datasource using pre-defined data.
    * This data is embedded in the library and does
    * not required any external data provider.
    * The test functions may assume that this data will
    * be unmodified forever by TA-LIB.
    */
   memset( &param, 0, sizeof( TA_AddDataSourceParam ) );
   param.id = TA_SIMULATOR;
   retCode = TA_AddDataSource( uDBase, &param );

   if( retCode != TA_SUCCESS )
   {
      printf( "TA_AddDataSource failed [%d]\n", retCode );
      freeLib( uDBase );
      return TA_REGTEST_ADDDATASOURCE_FAILED;
   }

   /* Regression testing of the functionality provided
    * by ta_period.c
    */
   retValue = test_period( uDBase );
   if( retValue != TA_TEST_PASS )
   {
      freeLib( uDBase );
      return retValue;
   }

   /* Allocate the reference historical data. */
   memset( &histParam, 0, sizeof( TA_HistoryAllocParam ) );
   histParam.category = "TA_SIM_REF";
   histParam.symbol   = "DAILY_REF_0";
   histParam.field    = TA_ALL;
   histParam.period   = TA_DAILY;
   retCode = TA_HistoryAlloc( uDBase, &histParam, &history );

   if( retCode != TA_SUCCESS )
   {
      printf( "TA_HistoryAlloc failed [%d]\n", retCode );
      freeLib( uDBase );
      return TA_REGTEST_HISTORYALLOC_FAILED;
   }

   /* Perform testing of each of the TA Functions. */
   retValue = testTAFunction_ALL( history );
   if( retValue != TA_TEST_PASS )
   {
      TA_HistoryFree( history );
      freeLib( uDBase );
      return retValue;
   }

   /* Clean-up and exit. */

   retCode = TA_HistoryFree( history );
   if( retCode != TA_SUCCESS )
   {
      printf( "TA_HistoryFree failed [%d]\n", retCode );
      freeLib( uDBase );
      return TA_REGTEST_HISTORYFREE_FAILED;
   }

   retValue = freeLib( uDBase );
   if( retValue != TA_TEST_PASS )
      return retValue;

   return TA_TEST_PASS; /* All test succeed. */
}