Skip to content

Instantly share code, notes, and snippets.

@niklio
Created October 28, 2016 16:49
Show Gist options
  • Save niklio/a47654912242aab5752ba434e7a00587 to your computer and use it in GitHub Desktop.
Save niklio/a47654912242aab5752ba434e7a00587 to your computer and use it in GitHub Desktop.
/*
* ============
* Alphabetizer
* ============
*
* File: AlphaTesting.cpp
* ----------------------
* This file contains the AlphaTesting class to unit test each function in
* Alphabetizer
*
* @author Nik Liolios
* @date 10/27/2016
*/
#include <sstream>
#include "macro.h"
#define unittest_symbol
#include "Alphabetizer.h"
#undef unittest_symbol
class AlphaTesting {
public:
void parse_order();
void _run();
void run();
};
void AlphaTesting::parse_order() {
assert(Alphabetizer::parse_order("f") == true);
assert(Alphabetizer::parse_order("r") == false);
assert_throw({Alphabetizer::parse_order("a");});
}
void AlphaTesting::_run() {
Alphabetizer a;
std::istringstream *i = new std::istringstream("");
assert(a._run(*i, true) == "");
delete i;
i = new std::istringstream("a c b");
assert(a._run(*i, true) == "a, b, c");
delete i;
i = new std::istringstream("a c b");
assert(a._run(*i, false) == "c, b, a");
delete i;
i = new std::istringstream("z z z x y y");
assert(a._run(*i, true) == "x, y, y, z, z, z");
delete i;
}
void AlphaTesting::run() {
parse_order();
_run();
}
int main() {
AlphaTesting t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment