From a841b86152ef8ab472a9f9df3bc3153691aa610b Mon Sep 17 00:00:00 2001 From: William Lachance Date: Tue, 11 Aug 2009 12:35:05 -0400 Subject: [PATCH] Basic support for checking (in)equality of std::string in C++ version --- cpp/t/wvtest.t.cc | 6 ++++++ cpp/wvtest.cc | 8 ++++++++ cpp/wvtest.h | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/cpp/t/wvtest.t.cc b/cpp/t/wvtest.t.cc index d445c06..aa028d6 100644 --- a/cpp/t/wvtest.t.cc +++ b/cpp/t/wvtest.t.cc @@ -7,4 +7,10 @@ WVTEST_MAIN("wvtest tests") WVPASSNE(1, 2); WVPASSEQ(1, 1); WVPASSLT(1, 2); + + WVPASSEQ("hello", "hello"); + WVPASSNE("hello", "hello2"); + + WVPASSEQ(std::string("hello"), std::string("hello")); + WVPASSNE(std::string("hello"), std::string("hello2")); } diff --git a/cpp/wvtest.cc b/cpp/wvtest.cc index 5653744..3931cca 100644 --- a/cpp/wvtest.cc +++ b/cpp/wvtest.cc @@ -382,6 +382,14 @@ bool WvTest::start_check_eq(const char *file, int line, } +bool WvTest::start_check_eq(const char *file, int line, + const std::string &a, const std::string &b, + bool expect_pass) +{ + return start_check_eq(file, line, a.c_str(), b.c_str(), expect_pass); +} + + bool WvTest::start_check_eq(const char *file, int line, int a, int b, bool expect_pass) { diff --git a/cpp/wvtest.h b/cpp/wvtest.h index dbbd1de..ac9a526 100644 --- a/cpp/wvtest.h +++ b/cpp/wvtest.h @@ -12,6 +12,7 @@ #endif #include +#include class WvTest { @@ -39,6 +40,9 @@ public: { start(file, line, condstr); check(cond); return cond; } static bool start_check_eq(const char *file, int line, const char *a, const char *b, bool expect_pass); + static bool start_check_eq(const char *file, int line, + const std::string &a, const std::string &b, + bool expect_pass); static bool start_check_eq(const char *file, int line, int a, int b, bool expect_pass); static bool start_check_lt(const char *file, int line, -- 2.39.2