From b692b78718663a01f961d812ba01014a649d0e48 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Feb 2016 11:38:08 +0100 Subject: [PATCH] Fixed: Tests for fromStringwith a boolean --HG-- branch : develop --- .../nel_unit_test/ut_misc_string_common.h | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/code/nel/tools/nel_unit_test/ut_misc_string_common.h b/code/nel/tools/nel_unit_test/ut_misc_string_common.h index 2fc646a36..33378a8ec 100644 --- a/code/nel/tools/nel_unit_test/ut_misc_string_common.h +++ b/code/nel/tools/nel_unit_test/ut_misc_string_common.h @@ -682,60 +682,59 @@ struct CUTMiscStringCommon : public Test::Suite // tests for bool bool val; - // true value - val = false; + // true values ret = NLMISC::fromString("1", val); - TEST_ASSERT(val); - TEST_ASSERT_MSG(ret, "should succeed"); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("t", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("t", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("y", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("y", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("T", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("T", val); + TEST_ASSERT(ret && val); - val = false; - NLMISC::fromString("Y", val); - TEST_ASSERT(val); + ret = NLMISC::fromString("Y", val); + TEST_ASSERT(ret && val); - val = true; + ret = NLMISC::fromString("true", val); + TEST_ASSERT(ret && val); + + ret = NLMISC::fromString("yes", val); + TEST_ASSERT(ret && val); + + // false values ret = NLMISC::fromString("0", val); - TEST_ASSERT(!val); - TEST_ASSERT_MSG(ret, "should succeed"); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("f", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("f", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("n", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("n", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("F", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("F", val); + TEST_ASSERT(ret && !val); - val = true; - NLMISC::fromString("N", val); - TEST_ASSERT(!val); + ret = NLMISC::fromString("N", val); + TEST_ASSERT(ret && !val); + + ret = NLMISC::fromString("false", val); + TEST_ASSERT(ret && !val); + + ret = NLMISC::fromString("no", val); + TEST_ASSERT(ret && !val); + + // wrong values + ret = NLMISC::fromString("YES", val); + TEST_ASSERT(!ret && !val); + + ret = NLMISC::fromString("foo", val); + TEST_ASSERT(!ret && !val); - // bad character ret = NLMISC::fromString("a", val); - TEST_ASSERT_MSG(!ret, "should not succeed"); - - val = true; - NLMISC::fromString("a", val); - TEST_ASSERT_MSG(val, "should not modify the value"); - - val = false; - NLMISC::fromString("a", val); - TEST_ASSERT_MSG(!val, "should not modify the value"); + TEST_ASSERT(!ret && !val); } };