From b5b05d6b19705300c4c7e602d25fe76f581a1924 Mon Sep 17 00:00:00 2001 From: Andreas Waidler Date: Sat, 6 Aug 2011 22:54:56 +0200 Subject: [PATCH] Moved tests from tests/src to tests and their fixed namespace. --- tests/{src => }/TestException.cxx | 20 ++++++++++---------- tests/{src => }/TestException.hxx | 11 ++++++++--- tests/{src => }/TestUtility.cxx | 28 ++++++++++++++-------------- tests/{src => }/TestUtility.hxx | 11 ++++++++--- tests/{src => }/UsageExamples.cxx | 10 +++++----- tests/{src => }/UsageExamples.hxx | 11 ++++++++--- tests/registry.cxx | 12 ++++++------ 7 files changed, 59 insertions(+), 44 deletions(-) rename tests/{src => }/TestException.cxx (78%) rename tests/{src => }/TestException.hxx (85%) rename tests/{src => }/TestUtility.cxx (77%) rename tests/{src => }/TestUtility.hxx (90%) rename tests/{src => }/UsageExamples.cxx (93%) rename tests/{src => }/UsageExamples.hxx (69%) diff --git a/tests/src/TestException.cxx b/tests/TestException.cxx similarity index 78% rename from tests/src/TestException.cxx rename to tests/TestException.cxx index 73296e2..aad236b 100644 --- a/tests/src/TestException.cxx +++ b/tests/TestException.cxx @@ -1,11 +1,11 @@ -#include +#include #include #include #include #include -void TestException::testCopyingOfShortMessage() +void tests::TestException::testCopyingOfShortMessage() { char* const cstr = new char[80]; strcpy(cstr, "TEST0001"); @@ -17,7 +17,7 @@ void TestException::testCopyingOfShortMessage() CPPUNIT_ASSERT_EQUAL(exp, act); } -void TestException::testWhetherLongMessageDoesNotOverflow() +void tests::TestException::testWhetherLongMessageDoesNotOverflow() { size_t length = libsex::Exception::LENGTH; std::string str; @@ -36,7 +36,7 @@ void TestException::testWhetherLongMessageDoesNotOverflow() } } -void TestException::testWhetherPreviousExceptionIsCloned() +void tests::TestException::testWhetherPreviousExceptionIsCloned() { CPPUNIT_ASSERT_EQUAL(0, CountingException::instances); CountingException e1("e1"); @@ -45,7 +45,7 @@ void TestException::testWhetherPreviousExceptionIsCloned() CPPUNIT_ASSERT_EQUAL(2, CountingException::instances); } -void TestException::testWhetherClonedExceptionIsDeleted() +void tests::TestException::testWhetherClonedExceptionIsDeleted() { CPPUNIT_ASSERT_EQUAL(0, CountingException::instances); @@ -58,13 +58,13 @@ void TestException::testWhetherClonedExceptionIsDeleted() CPPUNIT_ASSERT_EQUAL(1, CountingException::instances); } -void TestException::testWhetherBadAllocOnCloneIsSwallowed() +void tests::TestException::testWhetherBadAllocOnCloneIsSwallowed() { UncloneableException e1; libsex::Exception e2("e2", e1); } -void TestException::testWhetherNoticeIsAppendedOnBadAlloc() +void tests::TestException::testWhetherNoticeIsAppendedOnBadAlloc() { UncloneableException e1; libsex::Exception e2("e2", e1); @@ -77,7 +77,7 @@ void TestException::testWhetherNoticeIsAppendedOnBadAlloc() CPPUNIT_ASSERT_EQUAL(exp, act); } -void TestException::testWhetherNoticeDoesNotOverflowIfBufferTooSmall() +void tests::TestException::testWhetherNoticeDoesNotOverflowIfBufferTooSmall() { size_t length = libsex::Exception::LENGTH; std::string str; @@ -93,7 +93,7 @@ void TestException::testWhetherNoticeDoesNotOverflowIfBufferTooSmall() CPPUNIT_ASSERT_EQUAL(str, std::string(e2.what())); } -void TestException::testWritingToStream() +void tests::TestException::testWritingToStream() { std::string exp("TestException"); libsex::Exception e(exp.c_str()); @@ -104,7 +104,7 @@ void TestException::testWritingToStream() CPPUNIT_ASSERT_EQUAL(exp, act.str()); } -void TestException::testBacktrace() +void tests::TestException::testBacktrace() { libsex::Exception cause("Failed to foo."); libsex::Exception e("Failed to bar.", cause); diff --git a/tests/src/TestException.hxx b/tests/TestException.hxx similarity index 85% rename from tests/src/TestException.hxx rename to tests/TestException.hxx index 989d177..19ff153 100644 --- a/tests/src/TestException.hxx +++ b/tests/TestException.hxx @@ -1,9 +1,14 @@ -#ifndef TESTEXCEPTION_HXX -#define TESTEXCEPTION_HXX +#ifndef TESTS_TESTEXCEPTION_HXX +#define TESTS_TESTEXCEPTION_HXX #include -class TestException : public CppUnit::TestFixture +namespace tests +{ + class TestException; +} + +class tests::TestException : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestException); CPPUNIT_TEST(testCopyingOfShortMessage); diff --git a/tests/src/TestUtility.cxx b/tests/TestUtility.cxx similarity index 77% rename from tests/src/TestUtility.cxx rename to tests/TestUtility.cxx index f0c37c9..fbc3c78 100644 --- a/tests/src/TestUtility.cxx +++ b/tests/TestUtility.cxx @@ -1,11 +1,11 @@ -#include +#include #include #include #include -void TestUtility::testShortTemplateWithoutFormatting() +void tests::TestUtility::testShortTemplateWithoutFormatting() { char buf[100] = { 0 }; @@ -19,7 +19,7 @@ void TestUtility::testShortTemplateWithoutFormatting() CPPUNIT_ASSERT_EQUAL(exp, std::string(buf)); } -void TestUtility::testWhetherFalseIsReturnedWhenHeaderFillsBuffer() +void tests::TestUtility::testWhetherFalseIsReturnedWhenHeaderFillsBuffer() { char buf[100] = { 0 }; @@ -33,7 +33,7 @@ void TestUtility::testWhetherFalseIsReturnedWhenHeaderFillsBuffer() CPPUNIT_ASSERT_EQUAL(exp, std::string(buf)); } -void TestUtility::testWhetherTrueIsReturnedOnExactFit() +void tests::TestUtility::testWhetherTrueIsReturnedOnExactFit() { char buf[100] = { 0 }; @@ -47,7 +47,7 @@ void TestUtility::testWhetherTrueIsReturnedOnExactFit() CPPUNIT_ASSERT_EQUAL(exp, std::string(buf)); } -void TestUtility::testWhetherUnformattedOverflowsArePrevented() +void tests::TestUtility::testWhetherUnformattedOverflowsArePrevented() { // Array should be large enough to not really get // overwritten. Just adjust the parameter 'length' @@ -63,7 +63,7 @@ void TestUtility::testWhetherUnformattedOverflowsArePrevented() assertBoundary(buf, 10, 100); } -void TestUtility::testWhetherSimpleFormattingWorks() +void tests::TestUtility::testWhetherSimpleFormattingWorks() { char buf[100] = { 0 }; @@ -77,7 +77,7 @@ void TestUtility::testWhetherSimpleFormattingWorks() CPPUNIT_ASSERT_EQUAL(exp, std::string(buf)); } -void TestUtility::testWhetherFormattedOverflowsArePreventedBeforeFormatstring() +void tests::TestUtility::testWhetherFormattedOverflowsArePreventedBeforeFormatstring() { // Array should be large enough to not really get // overwritten. Just adjust the parameter 'length' @@ -93,7 +93,7 @@ void TestUtility::testWhetherFormattedOverflowsArePreventedBeforeFormatstring() assertBoundary(buf, 10, 100); } -void TestUtility::testWhetherFormattedOverflowsArePreventedInFormatstring() +void tests::TestUtility::testWhetherFormattedOverflowsArePreventedInFormatstring() { // Array should be large enough to not really get // overwritten. Just adjust the parameter 'length' @@ -109,7 +109,7 @@ void TestUtility::testWhetherFormattedOverflowsArePreventedInFormatstring() assertBoundary(buf, 28, 100); } -void TestUtility::testMultipleFormatParameters() +void tests::TestUtility::testMultipleFormatParameters() { char buf[100] = { 0 }; @@ -123,7 +123,7 @@ void TestUtility::testMultipleFormatParameters() CPPUNIT_ASSERT_EQUAL(exp, std::string(buf)); } -void TestUtility::testWhetherMultipleParametersDontOverflowBeforeFormatstring() +void tests::TestUtility::testWhetherMultipleParametersDontOverflowBeforeFormatstring() { char buf[100] = { 0 }; @@ -136,7 +136,7 @@ void TestUtility::testWhetherMultipleParametersDontOverflowBeforeFormatstring() assertBoundary(buf, 10, 100); } -void TestUtility::testWhetherMultipleParametersDontOverflowInFormatstring() +void tests::TestUtility::testWhetherMultipleParametersDontOverflowInFormatstring() { char buf[100] = { 0 }; @@ -149,7 +149,7 @@ void TestUtility::testWhetherMultipleParametersDontOverflowInFormatstring() assertBoundary(buf, 18, 100); } -void TestUtility::testTemplateFactory() +void tests::TestUtility::testTemplateFactory() { MockException e = libsex::formatted( @@ -161,7 +161,7 @@ void TestUtility::testTemplateFactory() std::string(e.what())); } -void TestUtility::testChainedTemplateFactory() +void tests::TestUtility::testChainedTemplateFactory() { MockException e1 = libsex::formatted( @@ -182,7 +182,7 @@ void TestUtility::testChainedTemplateFactory() act.str()); } -void TestUtility::assertBoundary( +void tests::TestUtility::assertBoundary( const char* const buffer, size_t boundary, size_t length) diff --git a/tests/src/TestUtility.hxx b/tests/TestUtility.hxx similarity index 90% rename from tests/src/TestUtility.hxx rename to tests/TestUtility.hxx index d252b0a..7ba30f5 100644 --- a/tests/src/TestUtility.hxx +++ b/tests/TestUtility.hxx @@ -1,9 +1,14 @@ -#ifndef TESTUTILITY_HXX -#define TESTUTILITY_HXX +#ifndef TESTS_TESTUTILITY_HXX +#define TESTS_TESTUTILITY_HXX #include -class TestUtility : public CppUnit::TestFixture +namespace tests +{ + class TestUtility; +} + +class tests::TestUtility : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestUtility); CPPUNIT_TEST(testShortTemplateWithoutFormatting); diff --git a/tests/src/UsageExamples.cxx b/tests/UsageExamples.cxx similarity index 93% rename from tests/src/UsageExamples.cxx rename to tests/UsageExamples.cxx index 602afbf..7e9c256 100644 --- a/tests/src/UsageExamples.cxx +++ b/tests/UsageExamples.cxx @@ -4,7 +4,7 @@ // Needed for the tests in this file, not part of the // examples. -#include +#include #include // Usage examples begin now. @@ -57,7 +57,7 @@ LIBSEX_DEFINE(libsex::Exception, Error, "Error!") /** * How to simply create an exception. */ -void UsageExamples::testSimpleConstruction() +void tests::UsageExamples::testSimpleConstruction() { // The error message. std::string msg("Someone has set us up the bomb!"); @@ -81,7 +81,7 @@ void UsageExamples::testSimpleConstruction() * How to throw a single exception without placeholders in * its message template. */ -void UsageExamples::testSimpleThrowing() +void tests::UsageExamples::testSimpleThrowing() { bool success = false; @@ -109,7 +109,7 @@ void UsageExamples::testSimpleThrowing() /** * How to throw a single exception. */ -void UsageExamples::testThrowing() +void tests::UsageExamples::testThrowing() { bool success = false; @@ -134,7 +134,7 @@ void UsageExamples::testThrowing() /** * How to chain exceptions. */ -void UsageExamples::testChaining() +void tests::UsageExamples::testChaining() { bool success = false; diff --git a/tests/src/UsageExamples.hxx b/tests/UsageExamples.hxx similarity index 69% rename from tests/src/UsageExamples.hxx rename to tests/UsageExamples.hxx index 1b98cde..89129a9 100644 --- a/tests/src/UsageExamples.hxx +++ b/tests/UsageExamples.hxx @@ -1,9 +1,14 @@ -#ifndef LIBSEX_TEST_USAGEEXAMPLES_HXX -#define LIBSEX_TEST_USAGEEXAMPLES_HXX +#ifndef TESTS_USAGEEXAMPLES_HXX +#define TESTS_USAGEEXAMPLES_HXX #include -class UsageExamples : public CppUnit::TestFixture +namespace tests +{ + class UsageExamples; +} + +class tests::UsageExamples : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(UsageExamples); CPPUNIT_TEST(testSimpleConstruction); diff --git a/tests/registry.cxx b/tests/registry.cxx index 7182446..fc428a7 100644 --- a/tests/registry.cxx +++ b/tests/registry.cxx @@ -3,11 +3,11 @@ // Registering all unit tests here, to make them // easier to disable and enable. -#include -CPPUNIT_TEST_SUITE_REGISTRATION(TestException); +#include +CPPUNIT_TEST_SUITE_REGISTRATION(tests::TestException); -#include -CPPUNIT_TEST_SUITE_REGISTRATION(TestUtility); +#include +CPPUNIT_TEST_SUITE_REGISTRATION(tests::TestUtility); -#include -CPPUNIT_TEST_SUITE_REGISTRATION(UsageExamples); +#include +CPPUNIT_TEST_SUITE_REGISTRATION(tests::UsageExamples); -- 2.11.4.GIT