From 11a181ce2e91427ac1a00e5992f6437f4cabb007 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Mon, 1 Aug 2016 05:56:44 +0000 Subject: [PATCH] Still fixing the unittests... - Fix argument order in ASSERT_EQUALS For a few tests the order of the arguments of ASSERT_EQUALS were swapped. Although it did not cause problems beacuse of the commutative nature of the equality operator, if such a test failed the reported error was incorrect and misleading. Also removed a duplicate test. - Fix an unused parameter warning - Fix unittest compilation with Boost enabled - Fix check for '%e' conversion The documentation says only that the exponent is at least two digits, not that it is exactly two digits. It depends on the underlying C Runtime Library how many digits are used. The check itself is meant only to check if a wrong type argument is accepted and handled as if it was a matching type, and it still fulfills that requirement. - Ensure we can read the source directory By checking early for the existence and readability of the source directory we can provide a different failure message from when the actual file I/O check fail. There are systems where the compiler's handling of non-ASCII characters is different from the OS's way. In such a system this test will fail if the source directory name contains non-ASCII characters. - The order does matter, #2 For some linker the order of the libraries on the command-line does matter. --- .svn-revision | 2 +- src/Logger.h | 2 + unittests/muleunit/main.cpp | 2 +- unittests/tests/FormatTest.cpp | 2 +- unittests/tests/Makefile.am | 6 +- unittests/tests/Makefile.in | 46 +++++++------ unittests/tests/NetworkFunctionsTest.cpp | 5 ++ unittests/tests/PathTest.cpp | 113 +++++++++++++------------------ unittests/tests/RangeMapTest.cpp | 20 +++--- unittests/tests/TextFileTest.cpp | 2 + 10 files changed, 98 insertions(+), 102 deletions(-) diff --git a/.svn-revision b/.svn-revision index 5d468dd8..64156aa2 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10942 +10943 diff --git a/src/Logger.h b/src/Logger.h index 1c0eeac6..00372a5f 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -432,6 +432,8 @@ public: #define AddDebugLogLineC(...) do {} while (false) #define AddLogLineC(...) do {} while (false) #define AddLogLineCS(...) do {} while (false) + #define AddDebugLogLineF(...) do {} while (false) + #define AddLogLineF(...) do {} while (false) #else // Macros for 'N'on critical logging #ifdef __DEBUG__ diff --git a/unittests/muleunit/main.cpp b/unittests/muleunit/main.cpp index b0ffcf1a..ef2a7d7c 100644 --- a/unittests/muleunit/main.cpp +++ b/unittests/muleunit/main.cpp @@ -42,7 +42,7 @@ public: return (TestRegistry::runAndPrint() ? 0 : 1); } - void OnAssertFailure(const wxChar* file, int line, const wxChar* func, const wxChar* cond, const wxChar* msg) + void OnAssertFailure(const wxChar* file, int line, const wxChar* /*func*/, const wxChar* cond, const wxChar* msg) { if (s_disableAssertions) { return; diff --git a/unittests/tests/FormatTest.cpp b/unittests/tests/FormatTest.cpp index c64c4e7d..0fbfac87 100644 --- a/unittests/tests/FormatTest.cpp +++ b/unittests/tests/FormatTest.cpp @@ -504,5 +504,5 @@ TEST(Format, DifferentArguments) // Tests for accepting mismatching argument type ASSERT_EQUALS(wxT("C"), CFormat(wxT("%c")) % 67); ASSERT_EQUALS(wxT("69"), CFormat(wxT("%i")) % wxT('E')); - ASSERT_EQUALS(wxT("1e+00"), CFormat(wxT("%.e")) % 1u); + ASSERT_EQUALS(wxString::Format(wxT("%.e"), 1.0), CFormat(wxT("%.e")) % 1u); } diff --git a/unittests/tests/Makefile.am b/unittests/tests/Makefile.am index a781ab18..499fd4ff 100644 --- a/unittests/tests/Makefile.am +++ b/unittests/tests/Makefile.am @@ -8,7 +8,7 @@ MUCPPFLAGS = -DMULEUNIT AM_CPPFLAGS = $(MULECPPFLAGS) -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)/src -I$(top_srcdir)/src/libs -I$(top_srcdir)/src/include $(MUCPPFLAGS) $(WXBASE_CPPFLAGS) AM_CXXFLAGS = $(MULECXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CXXFLAGS_ONLY) AM_LDFLAGS = $(MULELDFLAGS) -LDADD = $(WXBASE_LIBS) ../muleunit/libmuleunit.a +LDADD = ../muleunit/libmuleunit.a $(WXBASE_LIBS) MAINTAINERCLEANFILES = Makefile.in TESTS = CUInt128Test RangeMapTest FormatTest StringFunctionsTest NetworkFunctionsTest FileDataIOTest PathTest TextFileTest CTagTest @@ -32,7 +32,9 @@ StringFunctionsTest_SOURCES = StringFunctionsTest.cpp $(top_srcdir)/src/libs/com # Tests for the various network functions. NetworkFunctionsTest_SOURCES = NetworkFunctionsTest.cpp $(top_srcdir)/src/NetworkFunctions.cpp $(top_srcdir)/src/LibSocket.cpp $(top_srcdir)/src/libs/common/Format.cpp $(top_srcdir)/src/libs/common/strerror_r.c -NetworkFunctionsTest_CPPFLAGS = $(AM_CPPFLAGS) -DEC_REMOTE # Needed to avoid compiling the http-thread +NetworkFunctionsTest_CPPFLAGS = $(BOOST_CPPFLAGS) $(AM_CPPFLAGS) -DEC_REMOTE # Needed to avoid compiling the http-thread +NetworkFunctionsTest_LDFLAGS = $(BOOST_SYSTEM_LDFLAGS) $(AM_LDFLAGS) +NetworkFunctionsTest_LDADD = $(BOOST_SYSTEM_LIBS) $(LDADD) # Tests for the classes that implement the CFileDataIO interface FileDataIOTest_SOURCES = FileDataIOTest.cpp $(top_srcdir)/src/SafeFile.cpp $(top_srcdir)/src/CFile.cpp $(top_srcdir)/src/MemFile.cpp $(top_srcdir)/src/kademlia/utils/UInt128.cpp $(top_srcdir)/src/libs/common/StringFunctions.cpp $(top_srcdir)/src/Tag.cpp $(top_srcdir)/src/libs/common/Path.cpp $(top_srcdir)/src/libs/common/Format.cpp $(top_srcdir)/src/libs/common/strerror_r.c diff --git a/unittests/tests/Makefile.in b/unittests/tests/Makefile.in index d6197028..c871f387 100644 --- a/unittests/tests/Makefile.in +++ b/unittests/tests/Makefile.in @@ -77,28 +77,28 @@ am_CTagTest_OBJECTS = CTagTest.$(OBJEXT) SafeFile.$(OBJEXT) \ CTagTest_OBJECTS = $(am_CTagTest_OBJECTS) CTagTest_LDADD = $(LDADD) am__DEPENDENCIES_1 = -CTagTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +CTagTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_CUInt128Test_OBJECTS = CUInt128Test.$(OBJEXT) UInt128.$(OBJEXT) \ Format.$(OBJEXT) strerror_r.$(OBJEXT) CUInt128Test_OBJECTS = $(am_CUInt128Test_OBJECTS) CUInt128Test_LDADD = $(LDADD) -CUInt128Test_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +CUInt128Test_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_FileDataIOTest_OBJECTS = FileDataIOTest.$(OBJEXT) \ SafeFile.$(OBJEXT) CFile.$(OBJEXT) MemFile.$(OBJEXT) \ UInt128.$(OBJEXT) StringFunctions.$(OBJEXT) Tag.$(OBJEXT) \ Path.$(OBJEXT) Format.$(OBJEXT) strerror_r.$(OBJEXT) FileDataIOTest_OBJECTS = $(am_FileDataIOTest_OBJECTS) FileDataIOTest_LDADD = $(LDADD) -FileDataIOTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +FileDataIOTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_FormatTest_OBJECTS = FormatTest.$(OBJEXT) Format.$(OBJEXT) \ strerror_r.$(OBJEXT) FormatTest_OBJECTS = $(am_FormatTest_OBJECTS) FormatTest_LDADD = $(LDADD) -FormatTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +FormatTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_NetworkFunctionsTest_OBJECTS = \ NetworkFunctionsTest-NetworkFunctionsTest.$(OBJEXT) \ NetworkFunctionsTest-NetworkFunctions.$(OBJEXT) \ @@ -106,34 +106,36 @@ am_NetworkFunctionsTest_OBJECTS = \ NetworkFunctionsTest-Format.$(OBJEXT) \ NetworkFunctionsTest-strerror_r.$(OBJEXT) NetworkFunctionsTest_OBJECTS = $(am_NetworkFunctionsTest_OBJECTS) -NetworkFunctionsTest_LDADD = $(LDADD) +am__DEPENDENCIES_2 = ../muleunit/libmuleunit.a $(am__DEPENDENCIES_1) NetworkFunctionsTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a + $(am__DEPENDENCIES_2) +NetworkFunctionsTest_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(NetworkFunctionsTest_LDFLAGS) $(LDFLAGS) -o $@ am_PathTest_OBJECTS = PathTest.$(OBJEXT) Path.$(OBJEXT) \ StringFunctions.$(OBJEXT) PathTest_OBJECTS = $(am_PathTest_OBJECTS) PathTest_LDADD = $(LDADD) -PathTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +PathTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_RangeMapTest_OBJECTS = RangeMapTest.$(OBJEXT) RangeMapTest_OBJECTS = $(am_RangeMapTest_OBJECTS) RangeMapTest_LDADD = $(LDADD) -RangeMapTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +RangeMapTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_StringFunctionsTest_OBJECTS = StringFunctionsTest.$(OBJEXT) \ StringFunctions.$(OBJEXT) Path.$(OBJEXT) StringFunctionsTest_OBJECTS = $(am_StringFunctionsTest_OBJECTS) StringFunctionsTest_LDADD = $(LDADD) -StringFunctionsTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +StringFunctionsTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) am_TextFileTest_OBJECTS = TextFileTest-TextFileTest.$(OBJEXT) \ TextFileTest-Path.$(OBJEXT) \ TextFileTest-StringFunctions.$(OBJEXT) \ TextFileTest-TextFile.$(OBJEXT) TextFileTest_OBJECTS = $(am_TextFileTest_OBJECTS) TextFileTest_LDADD = $(LDADD) -TextFileTest_DEPENDENCIES = $(am__DEPENDENCIES_1) \ - ../muleunit/libmuleunit.a +TextFileTest_DEPENDENCIES = ../muleunit/libmuleunit.a \ + $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -421,7 +423,7 @@ MUCPPFLAGS = -DMULEUNIT AM_CPPFLAGS = $(MULECPPFLAGS) -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)/src -I$(top_srcdir)/src/libs -I$(top_srcdir)/src/include $(MUCPPFLAGS) $(WXBASE_CPPFLAGS) AM_CXXFLAGS = $(MULECXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CXXFLAGS_ONLY) AM_LDFLAGS = $(MULELDFLAGS) -LDADD = $(WXBASE_LIBS) ../muleunit/libmuleunit.a +LDADD = ../muleunit/libmuleunit.a $(WXBASE_LIBS) MAINTAINERCLEANFILES = Makefile.in # Tests for the CUInt128 class @@ -441,7 +443,9 @@ StringFunctionsTest_SOURCES = StringFunctionsTest.cpp $(top_srcdir)/src/libs/com # Tests for the various network functions. NetworkFunctionsTest_SOURCES = NetworkFunctionsTest.cpp $(top_srcdir)/src/NetworkFunctions.cpp $(top_srcdir)/src/LibSocket.cpp $(top_srcdir)/src/libs/common/Format.cpp $(top_srcdir)/src/libs/common/strerror_r.c -NetworkFunctionsTest_CPPFLAGS = $(AM_CPPFLAGS) -DEC_REMOTE # Needed to avoid compiling the http-thread +NetworkFunctionsTest_CPPFLAGS = $(BOOST_CPPFLAGS) $(AM_CPPFLAGS) -DEC_REMOTE # Needed to avoid compiling the http-thread +NetworkFunctionsTest_LDFLAGS = $(BOOST_SYSTEM_LDFLAGS) $(AM_LDFLAGS) +NetworkFunctionsTest_LDADD = $(BOOST_SYSTEM_LIBS) $(LDADD) # Tests for the classes that implement the CFileDataIO interface FileDataIOTest_SOURCES = FileDataIOTest.cpp $(top_srcdir)/src/SafeFile.cpp $(top_srcdir)/src/CFile.cpp $(top_srcdir)/src/MemFile.cpp $(top_srcdir)/src/kademlia/utils/UInt128.cpp $(top_srcdir)/src/libs/common/StringFunctions.cpp $(top_srcdir)/src/Tag.cpp $(top_srcdir)/src/libs/common/Path.cpp $(top_srcdir)/src/libs/common/Format.cpp $(top_srcdir)/src/libs/common/strerror_r.c @@ -506,7 +510,7 @@ FormatTest$(EXEEXT): $(FormatTest_OBJECTS) $(FormatTest_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) $(FormatTest_OBJECTS) $(FormatTest_LDADD) $(LIBS) NetworkFunctionsTest$(EXEEXT): $(NetworkFunctionsTest_OBJECTS) $(NetworkFunctionsTest_DEPENDENCIES) @rm -f NetworkFunctionsTest$(EXEEXT) - $(AM_V_CXXLD)$(CXXLINK) $(NetworkFunctionsTest_OBJECTS) $(NetworkFunctionsTest_LDADD) $(LIBS) + $(AM_V_CXXLD)$(NetworkFunctionsTest_LINK) $(NetworkFunctionsTest_OBJECTS) $(NetworkFunctionsTest_LDADD) $(LIBS) PathTest$(EXEEXT): $(PathTest_OBJECTS) $(PathTest_DEPENDENCIES) @rm -f PathTest$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(PathTest_OBJECTS) $(PathTest_LDADD) $(LIBS) diff --git a/unittests/tests/NetworkFunctionsTest.cpp b/unittests/tests/NetworkFunctionsTest.cpp index 59a88803..35884950 100644 --- a/unittests/tests/NetworkFunctionsTest.cpp +++ b/unittests/tests/NetworkFunctionsTest.cpp @@ -5,6 +5,11 @@ using namespace muleunit; +// Needed for Boost-enabled build +namespace MuleNotify { + void HandleNotificationAlways(const class CMuleNotiferBase&) {} +}; + DECLARE_SIMPLE(NetworkFunctions) TEST(NetworkFunctions, StringIPtoUint32) diff --git a/unittests/tests/PathTest.cpp b/unittests/tests/PathTest.cpp index 1bd2a01a..c757b236 100644 --- a/unittests/tests/PathTest.cpp +++ b/unittests/tests/PathTest.cpp @@ -134,13 +134,13 @@ TEST(CPath, PathConstructor) CPath tmp(input); ASSERT_TRUE(tmp.IsOk()); - ASSERT_EQUALS(tmp, CPath(input)); + ASSERT_EQUALS(CPath(input), tmp); - ASSERT_EQUALS(tmp.GetRaw(), ::GetExpectedString(input)); - ASSERT_EQUALS(tmp.GetPrintable(), result); + ASSERT_EQUALS(::GetExpectedString(input), tmp.GetRaw()); + ASSERT_EQUALS(result, tmp.GetPrintable()); - ASSERT_EQUALS(tmp.GetFullName(), tmp); - ASSERT_EQUALS(tmp.GetPath(), CPath()); + ASSERT_EQUALS(tmp, tmp.GetFullName()); + ASSERT_EQUALS(CPath(), tmp.GetPath()); } */ #endif @@ -155,36 +155,17 @@ TEST(CPath, CopyConstructor) CPath a(tmpPath); ASSERT_TRUE(a.IsOk()); - ASSERT_EQUALS(a.GetRaw(), tmpPath); - ASSERT_EQUALS(a.GetPrintable(), tmpPath); - ASSERT_EQUALS(a.GetPath(), CPath()); - ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath)); + ASSERT_EQUALS(tmpPath, a.GetRaw()); + ASSERT_EQUALS(tmpPath, a.GetPrintable()); + ASSERT_EQUALS(CPath(), a.GetPath()); + ASSERT_EQUALS(CPath(tmpPath), a.GetFullName()); CPath b(a); ASSERT_TRUE(b.IsOk()); - ASSERT_EQUALS(b.GetRaw(), tmpPath); - ASSERT_EQUALS(b.GetPrintable(), tmpPath); - ASSERT_EQUALS(b.GetPath(), CPath()); - ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath)); - - ASSERT_EQUALS(a, b); - } - - { - CPath a(tmpPath); - - ASSERT_TRUE(a.IsOk()); - ASSERT_EQUALS(a.GetRaw(), tmpPath); - ASSERT_EQUALS(a.GetPrintable(), tmpPath); - ASSERT_EQUALS(a.GetPath(), CPath()); - ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath)); - - CPath b(a); - ASSERT_TRUE(b.IsOk()); - ASSERT_EQUALS(b.GetRaw(), tmpPath); - ASSERT_EQUALS(b.GetPrintable(), tmpPath); - ASSERT_EQUALS(b.GetPath(), CPath()); - ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath)); + ASSERT_EQUALS(tmpPath, b.GetRaw()); + ASSERT_EQUALS(tmpPath, b.GetPrintable()); + ASSERT_EQUALS(CPath(), b.GetPath()); + ASSERT_EQUALS(CPath(tmpPath), b.GetFullName()); ASSERT_EQUALS(a, b); } @@ -212,18 +193,18 @@ TEST(CPath, Operators) ASSERT_FALSE(b.IsOk()); a = CPath(tmpPath1); - ASSERT_EQUALS(a.GetRaw(), tmpPath1); - ASSERT_EQUALS(a.GetPrintable(), tmpPath1); - ASSERT_EQUALS(a.GetPath(), CPath()); - ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath1)); + ASSERT_EQUALS(tmpPath1, a.GetRaw()); + ASSERT_EQUALS(tmpPath1, a.GetPrintable()); + ASSERT_EQUALS(CPath(), a.GetPath()); + ASSERT_EQUALS(CPath(tmpPath1), a.GetFullName()); ASSERT_TRUE(a.IsOk()); ASSERT_TRUE(a != b); b = a; - ASSERT_EQUALS(b.GetRaw(), tmpPath1); - ASSERT_EQUALS(b.GetPrintable(), tmpPath1); - ASSERT_EQUALS(b.GetPath(), CPath()); - ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath1)); + ASSERT_EQUALS(tmpPath1, b.GetRaw()); + ASSERT_EQUALS(tmpPath1, b.GetPrintable()); + ASSERT_EQUALS(CPath(), b.GetPath()); + ASSERT_EQUALS(CPath(tmpPath1), b.GetFullName()); ASSERT_TRUE(a.IsOk()); ASSERT_TRUE(b.IsOk()); ASSERT_EQUALS(a, b); @@ -233,14 +214,14 @@ TEST(CPath, Operators) ASSERT_TRUE(b.IsOk()); ASSERT_TRUE(a != b); - ASSERT_EQUALS(a.GetRaw(), tmpPath2); - ASSERT_EQUALS(a.GetPrintable(), tmpPath2); - ASSERT_EQUALS(a.GetPath(), CPath()); - ASSERT_EQUALS(a.GetFullName(), CPath(tmpPath2)); - ASSERT_EQUALS(b.GetRaw(), tmpPath1); - ASSERT_EQUALS(b.GetPrintable(), tmpPath1); - ASSERT_EQUALS(b.GetPath(), CPath()); - ASSERT_EQUALS(b.GetFullName(), CPath(tmpPath1)); + ASSERT_EQUALS(tmpPath2, a.GetRaw()); + ASSERT_EQUALS(tmpPath2, a.GetPrintable()); + ASSERT_EQUALS(CPath(), a.GetPath()); + ASSERT_EQUALS(CPath(tmpPath2), a.GetFullName()); + ASSERT_EQUALS(tmpPath1, b.GetRaw()); + ASSERT_EQUALS(tmpPath1, b.GetPrintable()); + ASSERT_EQUALS(CPath(), b.GetPath()); + ASSERT_EQUALS(CPath(tmpPath1), b.GetFullName()); } // See note in CPath::operator== @@ -329,36 +310,36 @@ TEST(CPath, IsSameDir) TEST(CPath, GetPath_FullName) { { - ASSERT_EQUALS(CPath().GetPath(), CPath()); - ASSERT_EQUALS(CPath().GetFullName(), CPath()); + ASSERT_EQUALS(CPath(), CPath().GetPath()); + ASSERT_EQUALS(CPath(), CPath().GetFullName()); } { const CPath path = Norm(wxT("/home/mule/")); - ASSERT_EQUALS(path.GetPath(), Norm(wxT("/home/mule"))); - ASSERT_EQUALS(path.GetFullName(), CPath()); + ASSERT_EQUALS(Norm(wxT("/home/mule")), path.GetPath()); + ASSERT_EQUALS(CPath(), path.GetFullName()); } { const CPath path = Norm(wxT("/home/mule")); - ASSERT_EQUALS(path.GetPath(), Norm(wxT("/home"))); - ASSERT_EQUALS(path.GetFullName(), Norm(wxT("mule"))); + ASSERT_EQUALS(Norm(wxT("/home")), path.GetPath()); + ASSERT_EQUALS(Norm(wxT("mule")), path.GetFullName()); } { const CPath path = Norm(wxT("mule")); - ASSERT_EQUALS(path.GetPath(), CPath()); - ASSERT_EQUALS(path.GetFullName(), Norm(wxT("mule"))); + ASSERT_EQUALS(CPath(), path.GetPath()); + ASSERT_EQUALS(Norm(wxT("mule")), path.GetFullName()); } { const CPath path = Norm(wxT("mule.ext")); - ASSERT_EQUALS(path.GetPath(), CPath()); - ASSERT_EQUALS(path.GetFullName(), Norm(wxT("mule.ext"))); + ASSERT_EQUALS(CPath(), path.GetPath()); + ASSERT_EQUALS(Norm(wxT("mule.ext")), path.GetFullName()); } } @@ -367,19 +348,19 @@ TEST(CPath, Cleanup) { const CPath initial = CPath(wxT(" /a\"b*c* ?e|\\:f ")); - ASSERT_EQUALS(initial.Cleanup(false, false), Norm(wxT("\%20a\"b*c*\%20?e|\\:f\%20"))); - ASSERT_EQUALS(initial.Cleanup(false, true), Norm(wxT("\%20abc\%20def\%20"))); - ASSERT_EQUALS(initial.Cleanup(true, false), Norm(wxT(" a\"b*c* ?e|\\:f "))); - ASSERT_EQUALS(initial.Cleanup(true, true), Norm(wxT(" abc def "))); + ASSERT_EQUALS(Norm(wxT("\%20a\"b*c*\%20?e|\\:f\%20")), initial.Cleanup(false, false)); + ASSERT_EQUALS(Norm(wxT("\%20abc\%20def\%20")), initial.Cleanup(false, true)); + ASSERT_EQUALS(Norm(wxT(" a\"b*c* ?e|\\:f ")), initial.Cleanup(true, false)); + ASSERT_EQUALS(Norm(wxT(" abc def ")), initial.Cleanup(true, true)); } TEST(CPath, AddPostFix) { - ASSERT_EQUALS(Norm(wxT("/foo.bar")).AddPostfix(wxT("_1")), Norm(wxT("/foo_1.bar"))); - ASSERT_EQUALS(Norm(wxT("/foo.bar")).AddPostfix(wxT("")), Norm(wxT("/foo.bar"))); - ASSERT_EQUALS(Norm(wxT("/.bar")).AddPostfix(wxT("_1")), Norm(wxT("/.bar_1"))); - ASSERT_EQUALS(Norm(wxT("/")).AddPostfix(wxT("_1")), Norm(wxT("/_1"))); + ASSERT_EQUALS(Norm(wxT("/foo_1.bar")), Norm(wxT("/foo.bar")).AddPostfix(wxT("_1"))); + ASSERT_EQUALS(Norm(wxT("/foo.bar")), Norm(wxT("/foo.bar")).AddPostfix(wxT(""))); + ASSERT_EQUALS(Norm(wxT("/.bar_1")), Norm(wxT("/.bar")).AddPostfix(wxT("_1"))); + ASSERT_EQUALS(Norm(wxT("/_1")), Norm(wxT("/")).AddPostfix(wxT("_1"))); } diff --git a/unittests/tests/RangeMapTest.cpp b/unittests/tests/RangeMapTest.cpp index 2400c47d..6756a790 100644 --- a/unittests/tests/RangeMapTest.cpp +++ b/unittests/tests/RangeMapTest.cpp @@ -118,7 +118,7 @@ DECLARE(RangeMap); // Test that the correct iterator was returned ASSERT_TRUE(it.keyStart() <= start); ASSERT_TRUE(it.keyEnd() >= end); - ASSERT_EQUALS(*it, value); + ASSERT_EQUALS(value, *it); // Check the resulting map ASSERT_EQUALS(result, StringFrom(m_map)); @@ -153,7 +153,7 @@ DECLARE(RangeMap); // Test that the correct iterator was returned ASSERT_TRUE(it.keyStart() <= start); ASSERT_TRUE(it.keyEnd() >= end); - ASSERT_EQUALS(*it, value); + ASSERT_EQUALS(value, *it); // Check the resulting map ASSERT_EQUALS(result, StringFrom(m_mmaps[type])); @@ -787,26 +787,26 @@ TEST(RangeMap, Swap) TestRangeMap mapA = m_mmaps[CONT]; TestRangeMap mapB = m_mmaps[SSAME]; - ASSERT_EQUALS(mapA, m_mmaps[CONT]); - ASSERT_EQUALS(mapB, m_mmaps[SSAME]); + ASSERT_EQUALS(m_mmaps[CONT], mapA); + ASSERT_EQUALS(m_mmaps[SSAME], mapB); std::swap(mapA, mapB); - ASSERT_EQUALS(mapB, m_mmaps[CONT]); - ASSERT_EQUALS(mapA, m_mmaps[SSAME]); + ASSERT_EQUALS(m_mmaps[CONT], mapB); + ASSERT_EQUALS(m_mmaps[SSAME], mapA); } { TestRangeMap mapA = m_mmaps[CONT]; TestRangeMap mapB = m_mmaps[SSAME]; - ASSERT_EQUALS(mapA, m_mmaps[CONT]); - ASSERT_EQUALS(mapB, m_mmaps[SSAME]); + ASSERT_EQUALS(m_mmaps[CONT], mapA); + ASSERT_EQUALS(m_mmaps[SSAME], mapB); mapA.swap(mapB); - ASSERT_EQUALS(mapB, m_mmaps[CONT]); - ASSERT_EQUALS(mapA, m_mmaps[SSAME]); + ASSERT_EQUALS(m_mmaps[CONT], mapB); + ASSERT_EQUALS(m_mmaps[SSAME], mapA); } } diff --git a/unittests/tests/TextFileTest.cpp b/unittests/tests/TextFileTest.cpp index 4fed34a2..b849f6bc 100644 --- a/unittests/tests/TextFileTest.cpp +++ b/unittests/tests/TextFileTest.cpp @@ -62,6 +62,8 @@ void CompareReadLines(size_t count, const wxChar* expected[], EReadTextFile crit TEST(TextFile, ReadLines) { + ASSERT_TRUE(CPath::DirExists(wxSTRINGIZE_T(SRCDIR))); + { CONTEXT(wxT("Checking default parameters")); -- 2.11.4.GIT