csci3081/testing/tests.cc
Michael Zhang 1ba4536588
f
2018-01-29 17:24:20 -06:00

44 lines
1,017 B
C++

#include <stdio.h>
#include <iostream>
#include <string>
#include "tests.h"
void ExpectEqual(std::string test, int expect, int got) {
std::cout << test << ":";
if (expect != got) {
printf("FAIL: expected %d, returned %d\n", expect, got);
} else {
printf("PASS\n");
}
}
void ExpectEqual(std::string test, float expect, float got) {
std::cout << test << ":";
if (expect != got) {
printf("FAIL:: expected %f, returned %f\n", expect, got);
} else {
printf("PASS\n");
}
}
void ExpectEqual(std::string test, bool expect, int got) {
char *expect_string;
char *got_string;
if (expect) {
expect_string = "True";
} else {
expect_string = "False";
}
if (got) {
got_string = "True";
} else {
got_string = "False";
}
std::cout << test << ":";
if (expect != got) {
printf("FAIL: expected %s, returned %s\n", expect_string, got_string);
} else {
printf("PASS\n");
}
}