From 47970ab16621b05973524eb9d4f6b0226dcb97eb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 17 Jul 2015 20:04:13 -0400 Subject: [PATCH] Test: Added ::closeEnough tests --- test/text.t.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/text.t.cpp b/test/text.t.cpp index 2aa48c1d4..d4894d6ab 100644 --- a/test/text.t.cpp +++ b/test/text.t.cpp @@ -37,7 +37,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (216); + UnitTest t (222); // Ensure environment has no influence. unsetenv ("TASKDATA"); @@ -411,10 +411,16 @@ int main (int argc, char** argv) t.is (rightJustify ("foo", 5), " foo", "rightJustify foo,5 -> ' foo'"); t.is (rightJustify ("föo", 5), " föo", "rightJustify föo,5 -> ' föo'"); - // int utf8_length (const std::string&); - t.is ((int) utf8_length ("Çirçös"), 6, "utf8_length (Çirçös) == 6"); - t.is ((int) utf8_length ("ツネナラム"), 5, "utf8_length (ツネナラム) == 5"); - t.is ((int) utf8_length ("Zwölf Boxkämpfer"), 16, "utf8_length (Zwölf Boxkämpfer) == 16"); + // bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0); + t.ok (closeEnough ("foobar", "foobar"), "closeEnough foobar == foobar"); + t.ok (closeEnough ("foobar", "foobar", 0), "closeEnough foobar == foobar,0"); + t.ok (closeEnough ("foobar", "foobar", 1), "closeEnough foobar == foobar,1"); + t.ok (closeEnough ("foobar", "foobar", 2), "closeEnough foobar == foobar,2"); + t.ok (closeEnough ("foobar", "foobar", 3), "closeEnough foobar == foobar,3"); + t.ok (closeEnough ("foobar", "foobar", 4), "closeEnough foobar == foobar,4"); + t.ok (closeEnough ("foobar", "foobar", 5), "closeEnough foobar == foobar,5"); + t.ok (closeEnough ("foobar", "foobar", 6), "closeEnough foobar == foobar,6"); + t.ok (closeEnough ("foobar", "foo", 3), "closeEnough foobar == foo,3"); return 0; }