Fixed: Tests for fromStringwith a boolean

--HG--
branch : develop
hg/feature/material-editor
kervala 9 years ago
parent 285965fe76
commit b692b78718

@ -682,60 +682,59 @@ struct CUTMiscStringCommon : public Test::Suite
// tests for bool // tests for bool
bool val; bool val;
// true value // true values
val = false;
ret = NLMISC::fromString("1", val); ret = NLMISC::fromString("1", val);
TEST_ASSERT(val); TEST_ASSERT(ret && val);
TEST_ASSERT_MSG(ret, "should succeed");
val = false; ret = NLMISC::fromString("t", val);
NLMISC::fromString("t", val); TEST_ASSERT(ret && val);
TEST_ASSERT(val);
val = false; ret = NLMISC::fromString("y", val);
NLMISC::fromString("y", val); TEST_ASSERT(ret && val);
TEST_ASSERT(val);
val = false; ret = NLMISC::fromString("T", val);
NLMISC::fromString("T", val); TEST_ASSERT(ret && val);
TEST_ASSERT(val);
val = false; ret = NLMISC::fromString("Y", val);
NLMISC::fromString("Y", val); TEST_ASSERT(ret && val);
TEST_ASSERT(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); ret = NLMISC::fromString("0", val);
TEST_ASSERT(!val); TEST_ASSERT(ret && !val);
TEST_ASSERT_MSG(ret, "should succeed");
val = true; ret = NLMISC::fromString("f", val);
NLMISC::fromString("f", val); TEST_ASSERT(ret && !val);
TEST_ASSERT(!val);
val = true; ret = NLMISC::fromString("n", val);
NLMISC::fromString("n", val); TEST_ASSERT(ret && !val);
TEST_ASSERT(!val);
val = true; ret = NLMISC::fromString("F", val);
NLMISC::fromString("F", val); TEST_ASSERT(ret && !val);
TEST_ASSERT(!val);
val = true; ret = NLMISC::fromString("N", val);
NLMISC::fromString("N", val); TEST_ASSERT(ret && !val);
TEST_ASSERT(!val);
// bad character ret = NLMISC::fromString("false", val);
ret = NLMISC::fromString("a", val); TEST_ASSERT(ret && !val);
TEST_ASSERT_MSG(!ret, "should not succeed");
val = true; ret = NLMISC::fromString("no", val);
NLMISC::fromString("a", val); TEST_ASSERT(ret && !val);
TEST_ASSERT_MSG(val, "should not modify the value");
val = false; // wrong values
NLMISC::fromString("a", val); ret = NLMISC::fromString("YES", val);
TEST_ASSERT_MSG(!val, "should not modify the value"); TEST_ASSERT(!ret && !val);
ret = NLMISC::fromString("foo", val);
TEST_ASSERT(!ret && !val);
ret = NLMISC::fromString("a", val);
TEST_ASSERT(!ret && !val);
} }
}; };

Loading…
Cancel
Save