testsuite: Improved const correctness of arguments.

This commit is contained in:
orbitcowboy 2017-10-30 10:57:03 +01:00
parent 3089352edb
commit 5ba5ea3aaf
2 changed files with 31 additions and 31 deletions

View File

@ -67,7 +67,7 @@ std::size_t TestFixture::todos_counter = 0;
std::size_t TestFixture::succeeded_todos_counter = 0;
std::set<std::string> TestFixture::missingLibs;
TestFixture::TestFixture(const char* _name)
TestFixture::TestFixture(const char * const _name)
:classname(_name)
,quiet_tests(false)
{
@ -116,7 +116,7 @@ static std::string writestr(const std::string &str, bool gccStyle = false)
return ostr.str();
}
void TestFixture::assert_(const char *filename, unsigned int linenr, bool condition) const
void TestFixture::assert_(const char * const filename, const unsigned int linenr, const bool condition) const
{
if (!condition) {
++fails_counter;
@ -124,7 +124,7 @@ void TestFixture::assert_(const char *filename, unsigned int linenr, bool condit
}
}
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
void TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
{
if (expected != actual) {
++fails_counter;
@ -163,25 +163,25 @@ std::string TestFixture::deleteLineNumber(const std::string &message) const
return result;
}
void TestFixture::assertEqualsWithoutLineNumbers(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
void TestFixture::assertEqualsWithoutLineNumbers(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg) const
{
assertEquals(filename, linenr, deleteLineNumber(expected), deleteLineNumber(actual), msg);
}
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const
void TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg) const
{
assertEquals(filename, linenr, std::string(expected), actual, msg);
}
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg) const
void TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const char actual[], const std::string &msg) const
{
assertEquals(filename, linenr, std::string(expected), std::string(actual), msg);
}
void TestFixture::assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg) const
void TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg) const
{
assertEquals(filename, linenr, expected, std::string(actual), msg);
}
void TestFixture::assertEquals(const char *filename, unsigned int linenr, long long expected, long long actual, const std::string &msg) const
void TestFixture::assertEquals(const char * const filename, const unsigned int linenr, const long long expected, const long long actual, const std::string &msg) const
{
if (expected != actual) {
std::ostringstream ostr1;
@ -192,7 +192,7 @@ void TestFixture::assertEquals(const char *filename, unsigned int linenr, long l
}
}
void TestFixture::assertEqualsDouble(const char *filename, unsigned int linenr, double expected, double actual, double tolerance, const std::string &msg) const
void TestFixture::assertEqualsDouble(const char * const filename, const unsigned int linenr, const double expected, const double actual, const double tolerance, const std::string &msg) const
{
if (expected < (actual - tolerance) || expected > (actual + tolerance)) {
std::ostringstream ostr1;
@ -203,7 +203,7 @@ void TestFixture::assertEqualsDouble(const char *filename, unsigned int linenr,
}
}
void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr,
void TestFixture::todoAssertEquals(const char * const filename, const unsigned int linenr,
const std::string &wanted,
const std::string &current,
const std::string &actual) const
@ -219,7 +219,7 @@ void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr,
}
}
void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr, long long wanted, long long current, long long actual) const
void TestFixture::todoAssertEquals(const char * const filename, const unsigned int linenr, const long long wanted, const long long current, const long long actual) const
{
std::ostringstream wantedStr, currentStr, actualStr;
wantedStr << wanted;
@ -228,7 +228,7 @@ void TestFixture::todoAssertEquals(const char *filename, unsigned int linenr, lo
todoAssertEquals(filename, linenr, wantedStr.str(), currentStr.str(), actualStr.str());
}
void TestFixture::assertThrow(const char *filename, unsigned int linenr) const
void TestFixture::assertThrow(const char * const filename, const unsigned int linenr) const
{
++fails_counter;
errmsg << filename << ':' << linenr << ": Assertion succeeded. "
@ -236,7 +236,7 @@ void TestFixture::assertThrow(const char *filename, unsigned int linenr) const
}
void TestFixture::assertThrowFail(const char *filename, unsigned int linenr) const
void TestFixture::assertThrowFail(const char * const filename, const unsigned int linenr) const
{
++fails_counter;
errmsg << filename << ':' << linenr << ": Assertion failed. "
@ -244,7 +244,7 @@ void TestFixture::assertThrowFail(const char *filename, unsigned int linenr) con
}
void TestFixture::assertNoThrowFail(const char *filename, unsigned int linenr) const
void TestFixture::assertNoThrowFail(const char * const filename, const unsigned int linenr) const
{
++fails_counter;
errmsg << filename << ':' << linenr << ": Assertion failed. "
@ -252,7 +252,7 @@ void TestFixture::assertNoThrowFail(const char *filename, unsigned int linenr) c
}
void TestFixture::complainMissingLib(const char* libname) const
void TestFixture::complainMissingLib(const char * const libname) const
{
missingLibs.insert(libname);
}

View File

@ -47,24 +47,24 @@ protected:
bool prepareTest(const char testname[]);
void assert_(const char *filename, unsigned int linenr, bool condition) const;
void assert_(const char * const filename, const unsigned int linenr, const bool condition) const;
void assertEquals(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
void assertEqualsWithoutLineNumbers(const char *filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const;
void assertEquals(const char *filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const;
void assertEquals(const char *filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const;
void assertEquals(const char *filename, unsigned int linenr, long long expected, long long actual, const std::string &msg = emptyString) const;
void assertEqualsDouble(const char *filename, unsigned int linenr, double expected, double actual, double tolerance, const std::string &msg = emptyString) const;
void assertEquals(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
void assertEqualsWithoutLineNumbers(const char * const filename, const unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const;
void assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const;
void assertEquals(const char * const filename, const unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const;
void assertEquals(const char * const filename, const unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const;
void assertEquals(const char * const filename, const unsigned int linenr, const long long expected, const long long actual, const std::string &msg = emptyString) const;
void assertEqualsDouble(const char * const filename, const unsigned int linenr, const double expected, const double actual, const double tolerance, const std::string &msg = emptyString) const;
void todoAssertEquals(const char *filename, unsigned int linenr, const std::string &wanted,
void todoAssertEquals(const char * const filename, const unsigned int linenr, const std::string &wanted,
const std::string &current, const std::string &actual) const;
void todoAssertEquals(const char *filename, unsigned int linenr, long long wanted,
long long current, long long actual) const;
void assertThrow(const char *filename, unsigned int linenr) const;
void assertThrowFail(const char *filename, unsigned int linenr) const;
void assertNoThrowFail(const char *filename, unsigned int linenr) const;
void complainMissingLib(const char* libname) const;
void todoAssertEquals(const char * const filename, const unsigned int linenr, const long long wanted,
const long long current, const long long actual) const;
void assertThrow(const char * const filename, const unsigned int linenr) const;
void assertThrowFail(const char * const filename, const unsigned int linenr) const;
void assertNoThrowFail(const char * const filename, const unsigned int linenr) const;
void complainMissingLib(const char * const libname) const;
std::string deleteLineNumber(const std::string &message) const;
@ -74,7 +74,7 @@ public:
virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
void run(const std::string &str);
explicit TestFixture(const char* _name);
explicit TestFixture(const char * const _name);
virtual ~TestFixture() { }
static std::size_t runTests(const options& args);