void
TestRecurrentTransaction::testGetMemo() {
    auto memo = QString("Dinner with friends");
    auto numberOfDays = 3;
    auto amount = .45;
    auto account = std::make_shared<PublicAccount>("Test account", .0, "");
    auto category = std::make_shared<com::chancho::Category>("Sushi", com::chancho::Category::Type::EXPENSE);
    auto transactionPtr = std::make_shared<com::chancho::Transaction>(account, amount, category);
    transactionPtr->memo = memo;
    auto recurrentPtr = std::make_shared<com::chancho::RecurrentTransaction>(transactionPtr,
        std::make_shared<com::chancho::RecurrentTransaction::Recurrence>(numberOfDays, QDate::currentDate()));

    auto qmlTransaction = std::make_shared<com::chancho::tests::PublicRecurrentTransaction>(recurrentPtr);
    QCOMPARE(qmlTransaction->getMemo(), memo);
}
Beispiel #2
0
Config Strategy::getNewConfigRandom(const_device_ptr device){
	int configNum;
	if(remainingConfigs.size() && getMemo()){ // might need a -1 here for numConfigs
		int r = randint(remainingConfigs.size());
		configNum = remainingConfigs[r];
		vector<int>::iterator it;
		for(it=remainingConfigs.begin();it!=remainingConfigs.end();it++){
			if(*it == configNum){
				remainingConfigs.erase(it);
				break;
			}
		}
		return device->getConfig(configNum);
	}
	// If already tried all the new random ones, return anything
	else{
		return device->getConfig(randint(device->getNumConfigs()));
	}
}
Beispiel #3
0
void Strategy::memoizeConfig(Config c) {

	if(getMemo()){
		int configNum = c.getConfigNum();
		if(!lookupConfig(configNum,c)){
			saveConfig(c);
			duration += c.getDuration();
			totalEnergy += c.getEnergy();

			if(limited)
			{
				switch(limitType.amountType)
				{
				case ENERGY:
					limitType.amount -= c.getEnergy();
					break;
				case DURATION:
					limitType.amount -= c.getDuration();
					break;
				case MEMORY:
					limitType.amount -= ENTRY_MEMORY*1; // Each new entry takes one memory space
					break;
				}
				if(limitType.amount <= 0)
				{
					overLimit = true;
					cout << "Overlimit!" << endl;
				}
				else{
#ifdef DEBUG
					cout << "Remaining: " << limitType.amount << endl;
#endif
				}
			}
		}
	}
}