Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Old-School-Game/tests.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (38 sloc)
1.41 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "objects.h" | |
#include "timer.h" | |
#include <iostream> | |
#include <iterator> | |
#include <thread> | |
using namespace std; | |
void printCocktailMetadata(Beverage bev){ | |
cout << "------------------" << endl << "Cocktail Metadata:" << endl << "------------------" << endl << "Name: " << bev.getName() << endl << "Glass type: "; | |
cout << bev.getGlassType() << endl; | |
cout << "Decoration: "; | |
cout << bev.getDecoration() << endl; | |
cout << "Recipe: "; | |
std::vector<string> recipe = bev.getRecipe(); | |
for(std::vector<string>::iterator recipeIterator = recipe.begin(); recipeIterator != recipe.end(); recipeIterator++) | |
{ | |
cout << *recipeIterator << " + "; | |
} | |
cout << endl; | |
} | |
void testTimer(int seconds){ | |
Timer timer = Timer(seconds); | |
cout << " Timer set to " << seconds << " seconds. Waiting 5 seconds (but already taken 1 to execute)." << endl; | |
std::this_thread::sleep_for(std::chrono::seconds(5)); | |
cout << timer.getSeconds() << " secs, " << timer.getMinutes() << " mins" << endl; | |
} | |
int main(){ | |
Database db = Database("cocktail.db"); | |
//Helper helper = Helper(); | |
initialiseObjectsFromDatabase(db); | |
cout << "COCKTAIL TEST:" << endl; | |
vector<Row> bevs = db.query("SELECT * FROM Beverage"); | |
for(int cocktail = 0; cocktail < bevs.size(); cocktail++){ | |
printCocktailMetadata(rowToCocktail(bevs[cocktail], db)); | |
} | |
cout << endl << "TIMER TEST:" << endl; | |
testTimer(5); | |
return 0; | |
} |