Skip to content
Snippets Groups Projects
Commit fd6802b5 authored by toole1's avatar toole1
Browse files

jack

git-svn-id: https://subversion.cs.illinois.edu/svn/cs225@3369 6fbd10e7-183d-0410-a318-cb416676e4f2
parent c36c4244
No related branches found
No related tags found
No related merge requests found
CC = g++
CFLAGS = -Wall
EXENAME = monad
OBJS = $(EXENAME).o util.o output.o
OBJS = $(EXENAME).o util.o monad_shared.o
IDFILE = .monadid
OPTIMIZE = off
......
CC = g++
CFLAGS += -Wall
TESTEXE = proxy
TESTOBJS += $(TESTEXE).o util.o unit_tests.o output.o
TESTOBJS += $(TESTEXE).o util.o unit_tests.o monad_shared.o
OPTIMIZE = off
ifeq ($(strip $(OPTIMIZE)),on)
......
......@@ -7,11 +7,10 @@
[Monad Files]
Makefile.proxy
memcheck.h
output.cpp
output.h
proxy.cpp
monad_shared.h
monad_shared.cpp
proxy.h
unit_test.h
proxy.cpp
valgrind.h
[Libraries]
......
......@@ -14,11 +14,11 @@
#include <vector>
#include "util.h"
#include "output.h"
#include "proxy.h"
using namespace std;
using namespace util;
using namespace output;
using namespace monad_shared;
namespace monad
{
......
#include <iostream>
#include "output.h"
#include "monad_shared.h"
#include "util.h"
using namespace proxy;
using namespace monad_shared;
using namespace util;
using std::cout;
using std::cerr;
using std::endl;
namespace monad_shared
{
const char * unit_test::pass_string = "~~PASSED~~";
namespace output
{
......@@ -17,6 +21,24 @@ void header(const string & title)
<< "================================" << endl;
}
void warning(const string & message)
{
cerr << endl
<< "********************************"
"********************************" << endl
<< "WARNING!" << endl
<< message << endl
<< "********************************"
"********************************" << endl << endl;
}
void total_score(int32_t score)
{
output::header("Total score (out of 100)");
cout << "TOTAL SCORE: " << score << endl << endl;
}
void testname(const unit_test & curr_test, int32_t max_testname_len, int32_t max_points_len)
{
// Output test name
......@@ -56,25 +78,6 @@ void testname(const unit_test & curr_test, int32_t max_testname_len, int32_t max
}
void warning(const string & message)
{
cerr << endl
<< "********************************"
"********************************" << endl
<< "WARNING!" << endl
<< message << endl
<< "********************************"
"********************************" << endl << endl;
}
void total_score(int32_t score)
{
output::header("Total score (out of 100)");
cout << "TOTAL SCORE: " << score << endl << endl;
}
void detailed_info(const unit_test & curr_test)
{
std::cout << "--------------------------------" << endl
......@@ -85,7 +88,7 @@ void detailed_info(const unit_test & curr_test)
const string & error = curr_test.errormsg;
const string & output = curr_test.output;
if (error == PASS_STRING)
if (curr_test.passed())
std::cout << "Result: passed" << endl;
else
std::cout << "Result: FAILED: " << error << endl;
......@@ -112,5 +115,6 @@ void detailed_info(const unit_test & curr_test)
}
} // namespace testoutput
} // namespace output
} // namespace monad_shared
#ifndef UNIT_TEST_H
#define UNIT_TEST_H
#ifndef MONAD_SHARED
#define MONAD_SHARED
#include <string>
#include "util.h"
#include "pipestream.h"
namespace proxy
namespace monad_shared
{
class RunTests;
struct unit_test
{
typedef std::string return_type;
......@@ -48,8 +46,15 @@ namespace proxy
return errormsg == pass_string;
}
};
}
#define PASS_STRING "~~PASSED~~"
namespace output
{
void header(const std::string & title);
void total_score(int32_t score);
void warning(const std::string & message);
void testname(const unit_test & curr_test, int32_t max_testname_len, int32_t max_points_len);
void detailed_info(const unit_test & curr_test);
} // namespace output
}
#endif
#endif // MONAD_SHARED
#ifndef OUTPUT_H
#define OUTPUT_H
#include <string>
#include "unit_test.h"
namespace output
{
void header(const std::string & title);
void total_score(int32_t score);
void testname(const proxy::unit_test & curr_test, int32_t max_testname_len, int32_t max_points_len);
void warning(const std::string & message);
void detailed_info(const proxy::unit_test & curr_test);
} // namespace output
#endif
......@@ -17,7 +17,7 @@
#include <iomanip>
#include "memcheck.h"
#include "output.h"
#include "monad_shared.h"
#include "pipestream.h"
#include "proxy.h"
#include "util.h"
......@@ -28,13 +28,12 @@ using std::vector;
using std::pair;
using namespace util;
using namespace output;
using namespace monad_shared;
namespace proxy
{
vector<unit_test> * global_tests = NULL;
output_check_map * global_output_checks = NULL;
const char * unit_test::pass_string = "~~PASSED~~";
}
......@@ -250,7 +249,7 @@ int32_t RunTests::run_single_test(unit_test & curr_test)
if (error == "")
error = "Unexpectedly Aborted";
if (error == PASS_STRING)
if (curr_test.passed())
cout << environment.single_test_passed_string << endl;
else
cout << "Result: FAILED:" << endl << error << endl;
......@@ -522,7 +521,7 @@ void UnitTestContainer::child_test(pipestream & fmsg_pipe, pipestream & nums_pip
fmsg_pipe.close();
// write time and valgrind flags to pipe
bool test_failed = (*error_msg != PASS_STRING);
bool test_failed = (*error_msg != unit_test::pass_string);
delete error_msg;
delete test.checkstream;
environment.cleanup_globals();
......@@ -562,7 +561,7 @@ void UnitTestContainer::test_exit(pipestream & fmsg_pipe, pipestream & nums_pipe
nums_pipe.close();
// Check for output's correctness, if that was a condition of passing
if (test.errormsg == PASS_STRING)
if (test.passed())
{
while (!test.checkstream->eof())
{
......@@ -620,7 +619,7 @@ int32_t get_valgrind_flags(bool test_failed)
const char * get_valgrind_string(int32_t flags)
{
if (flags == 0) return PASS_STRING;
if (flags == 0) return unit_test::pass_string;
bool test_failed = bitflag(flags, 0);
bool errors = bitflag(flags, 1);
......
......@@ -3,8 +3,8 @@
// unit_tests.cpp.
// By Jack Toole for CS 225 spring 2011
#ifndef RUNTESTS_H
#define RUNTESTS_H
#ifndef MONAD_PROXY_H
#define MONAD_PROXY_H
#include <map>
#include <string>
......@@ -12,16 +12,17 @@
#include <iostream>
#include <utility>
#include "pipestream.h"
#include "monad_shared.h"
#include "unit_test.h"
#define NO_MP_PART -1
#include "_mp_part_number.h"
#define MP_PART(x) (MP_PART_NUMBER == (x) || MP_PART_NUMBER == NO_MP_PART)
namespace proxy
{
using namespace monad_shared;
class RunTests;
struct unit_test;
typedef bool (*output_check)(const std::string &, const std::string &);
extern std::vector<unit_test> * global_tests;
......@@ -177,7 +178,7 @@ using std::endl;
#define FAIL(error) return std::string(__FILE__ ":" STR(__LINE__) ": ") + (error)
#define PASS return PASS_STRING
#define PASS return monad_shared::unit_test::pass_string;
#define ASSERT(expr) if (!(expr)) \
FAIL("Assertion (" #expr ") failed")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment