Hi.
How do I develop test cases for this code? Like, you know, testing the methods. I don't really know. If there was a "return", I could do it that way, but there isn't. So, you make a skeleton of tests, then adjust each test so that it actually tests the method (the method should pass, since it already works). Does anybody know how I do this here?
ElectionResults.h
#ifndef ELECTIONRESULTS_H
#define ELECTIONRESULTS_H
#include <string>
#include <iosfwd>
/** Class to represent vote ElectionResults */
class ElectionResults {
public:
/** Construct an empty ElectionResults */
ElectionResults(): num_candidates(0), num_precincts(0), vote_array(0) {}
/***************************************…
* Load vote data from file
* @param filename String
* @return boolean True if successful, false otherwise
*/
bool load_from_file(const std::string&);
/***************************************…
* Manually load vote ElectionResults
* @param numPrecincts size_t
* @param numCandidates size_t
* @param voteArray int[][] Each row contains a candidate and each column
* represents a precinct
*/
bool manual_load(size_t, size_t, int**);
/***************************************…
* Edit a particular entry in the voting table
* @param precinct size_t
* @param candidate size_t
* @param numVotes int
*/
bool edit_vote_data(size_t, size_t, int);
/***************************************…
* Creates a table of raw voting results
* @param out The ostream to write the results
*/
void generate_raw_table(std::ostream&);
/***************************************…
* Generate a table of voting results in percentage format
* @param out The ostream to write the results
*/
void generate_percentage_table(std::ostream&)…
/***************************************…
* Retrieve the top candidates
* @param num size_t Number of candidates to retrieve
* @param out The ostream to write the results
*/
void display_top_candidates(size_t, std::ostream&);
private:
/** The number of candidates */
size_t num_candidates;
/** The number of precincts */
size_t num_precincts;
/** The array to contain the votes */
int** vote_array;
};
#endif