Ejemplo n.º 1
0
bool SundanceGlobal:: passFailTest(const std::string& statusMsg,
  bool status, double error, double tol)
{
  MPIComm::world().synchronize();
  bool pass;
  if (MPIComm::world().getRank()==0)
  {

    cout << statusMsg << ": ";
    if (status) cout << "true" << std::endl;
    else cout << "false" << std::endl;
    cout << "error norm = " << error << std::endl;
    cout << "tolerance = " << tol << std::endl;
  }
  pass = checkTest(error, tol);
  if (MPIComm::world().getRank()==0)
  {
    if (status && pass)
    {
      cout << "test PASSED" << std::endl;
    }
    else
    {
      cout << "test FAILED" << std::endl;
    }
  }
  testStatus() = pass!=true;
  return pass;
}
Ejemplo n.º 2
0
void SundanceGlobal::handleException(std::exception& e)
{
  cout << "Sundance detected exception: " << std::endl;
  cout << e.what() << std::endl;
  cout << "test FAILED" << std::endl;
  testStatus() = -1;
}
Ejemplo n.º 3
0
int main (int argc, char** argv) {
	puts("Testing card gardens...");
	
	srand(time(NULL)); // Seed rand function
	/* Prepare arguments for initializeGame */
	int numPlayers = rand() % 3 + 2;
	int randomSeed = rand();
	int k[10] = {adventurer, gardens, embargo, village, minion,
		mine, cutpurse, sea_hag, tribute, smithy};
	struct gameState G;
	
	/* Run initializeGame function */
	initializeGame(numPlayers, k, randomSeed, &G);
	
	G.hand[0][0] = gardens;
	int handCountBefore = numHandCards(&G);
	
	int returnValue = playCard(0, 0, 0, 0, &G);
	assert(returnValue == 0);
	
	int handCountAfter = numHandCards(&G);
	// discard gardens
	assert(handCountAfter == (handCountBefore - 1));
	
	testStatus();
	
	return 0;
}
 /** Compares two addons according to the sort order currently defined.
  *  \param a The addon to compare this addon to.
  */
 bool operator<(const Addon &a) const
 {
     switch(m_sort_order)
     {
     case SO_DEFAULT: 
         if(testStatus(AS_FEATURED) && 
             !a.testStatus(AS_FEATURED))  return true;
         if(!testStatus(AS_FEATURED) && 
             a.testStatus(AS_FEATURED))  return false;
         // Otherwise fall through to name comparison!
         case SO_NAME:
             // m_id is the lower case name
             return m_id < a.m_id;
             break;
         case SO_DATE:
             return m_date > a.m_date;
             break;
     }   // switch
     // Fix compiler warning.
     return true;
 }   // operator<
Ejemplo n.º 5
0
bool SundanceGlobal:: passFailTest(bool pass)
{
  MPIComm::world().synchronize();
  if (MPIComm::world().getRank()==0)
  {
    if (pass)
    {
      cout << "test PASSED" << std::endl;
    }
    else
    {
      cout << "test FAILED" << std::endl;
    }
  }
  testStatus() = pass!=true;
  return pass;
}
Ejemplo n.º 6
0
bool SundanceGlobal:: passFailTest(double error, double tol)
{
  MPIComm::world().synchronize();
  bool pass;
  if (MPIComm::world().getRank()==0)
  {
    cout << "error norm = " << error << std::endl;
    cout << "tolerance = " << tol << std::endl;
  }
  pass = checkTest(error, tol);
  if (MPIComm::world().getRank()==0)
  {
    if (pass)
    {
      cout << "test PASSED" << std::endl;
    }
    else
    {
      cout << "test FAILED" << std::endl;
    }
  }
  testStatus() = pass!=true;
  return pass;
}
Ejemplo n.º 7
0
int main(int argc, const char **argv)
{
	Params       params;
	SCARDCONTEXT ctx;

	int          returnValue = 0;

	if (0 != parseCommandLine(argc, argv, &params))
		return -1;

	long ret = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &ctx);
	CHECK_PCSC_RET("SCardEstablishContext", ret);
	if (SCARD_S_SUCCESS == ret)
	{
		char       readerList[2000];

#ifdef LOOP_LIST_READERS
again:
#endif

		const char *readerName = listReaders(ctx, readerList, sizeof(readerList),
			'l' == params.command, params.readerNr);

#ifdef LOOP_LIST_READERS
		if (params.command == 'l')
		{
			getchar();
			goto again;
		}
#endif

		if (NULL != readerName)
		{
			switch (params.command) {
			case 's':
				getStatusChange(ctx, readerList, params.timeout);
				break;
			case 'l':
				// already done in listReaders()
				break;
			case 'a':
				sendAPDUS(ctx, readerName, params.apduCount, params.apdus);
				break;
			case 'f':
				testCardFunctionality(ctx, readerName);
				break;
			case 't':
				testAPDUS(ctx, readerName, params.chipnr);
				break;
			case 'x':
				switch (params.test) {
				case 1:
					returnValue = testStatus(ctx, readerName, readerList);
					break;
				case 2:
					returnValue = testConnect(ctx, readerName);
					break;
				case 3:
					returnValue = testTransaction(ctx, readerName);
					break;
				case 4:
					returnValue = testTransmit(ctx, readerName, params.apdus);
					break;
				default:
					printf("Unknown -x parameter '%d', exiting\n", params.test);
				}

				break;
			default:
				printf("Unknown command '%c', exiting\n", params.command);
			}
		}
	}

	ret = SCardReleaseContext(ctx);

	return returnValue;
}