diff --git a/testfiles/subdir/nested-testfile.txt b/testfiles/subdir/nested-testfile.txt new file mode 100644 index 0000000..7a1c613 --- /dev/null +++ b/testfiles/subdir/nested-testfile.txt @@ -0,0 +1 @@ +some file diff --git a/tests/misctests.cpp b/tests/misctests.cpp index 398c675..3b9a22a 100644 --- a/tests/misctests.cpp +++ b/tests/misctests.cpp @@ -1,23 +1,34 @@ #include "../misc/levenshtein.h" #include "../misc/multiarray.h" + +#include "../conversion/stringbuilder.h" + +#include "../io/misc.h" + #include "../tests/testutils.h" #include #include +#include + using namespace std; +using namespace ConversionUtilities; +using namespace IoUtilities; using namespace MiscUtilities; +using namespace TestUtilities; using namespace TestUtilities::Literals; using namespace CPPUNIT_NS; /*! - * \brief The MiscTests class tests functions and classes from the misc directory. + * \brief The MiscTests class tests misc functions and classes (mainly of files contained by the misc directory). */ class MiscTests : public TestFixture { CPPUNIT_TEST_SUITE(MiscTests); CPPUNIT_TEST(testMultiArray); CPPUNIT_TEST(testLevenshtein); + CPPUNIT_TEST(testTestUtilities); CPPUNIT_TEST_SUITE_END(); public: @@ -30,6 +41,7 @@ public: void testMultiArray(); void testLevenshtein(); + void testTestUtilities(); }; CPPUNIT_TEST_SUITE_REGISTRATION(MiscTests); @@ -123,3 +135,18 @@ void MiscTests::testLevenshtein() CPPUNIT_ASSERT_EQUAL(1_st, computeDamerauLevenshteinDistance("xxöxx", "xxäxx")); CPPUNIT_ASSERT_EQUAL(11_st, computeDamerauLevenshteinDistance("this is a long text", "this is too long for stack")); } + +/*! + * \brief Tests helper from TestUtilities namespace which aren't used in other tests anyways. + */ +void MiscTests::testTestUtilities() +{ + const auto workingCopyPathForNestedTestFile = workingCopyPath("subdir/nested-testfile.txt"); + CPPUNIT_ASSERT_EQUAL_MESSAGE("creation of subdirectories in working dir", "some file\n"s, readFile(workingCopyPathForNestedTestFile)); + + stringstream ss; + ss << asHexNumber(16); + CPPUNIT_ASSERT_EQUAL_MESSAGE("printing hex numbers", "0x10"s, ss.str()); + + TESTUTILS_ASSERT_LIKE("assert like works", ".*foo.*", " foo "); +}