MathLib: Added test for isDec() and removed not required state.
This commit is contained in:
parent
fafcf40ee6
commit
b9a9f51fe0
|
@ -464,7 +464,7 @@ bool MathLib::isBin(const std::string& s)
|
|||
bool MathLib::isDec(const std::string & s)
|
||||
{
|
||||
enum Status {
|
||||
START, PLUSMINUS, DIGIT, SUFFIX
|
||||
START, PLUSMINUS, DIGIT
|
||||
} state = START;
|
||||
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||
switch (state) {
|
||||
|
@ -488,8 +488,6 @@ bool MathLib::isDec(const std::string & s)
|
|||
else
|
||||
return isValidSuffix(it,s.end());
|
||||
break;
|
||||
case SUFFIX:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return state == DIGIT;
|
||||
|
|
|
@ -31,6 +31,7 @@ private:
|
|||
void run() {
|
||||
TEST_CASE(isint);
|
||||
TEST_CASE(isbin);
|
||||
TEST_CASE(isdec);
|
||||
TEST_CASE(isoct);
|
||||
TEST_CASE(ishex);
|
||||
TEST_CASE(isnegative);
|
||||
|
@ -613,6 +614,24 @@ private:
|
|||
ASSERT_EQUALS("-inf.0", MathLib::divide("-3.0", "0.0f")); // -inf (#5142)
|
||||
ASSERT_EQUALS("inf.0", MathLib::divide("-3.0", "-0.0f")); // inf (#5142)
|
||||
}
|
||||
|
||||
void isdec(void)
|
||||
{
|
||||
// positive testing
|
||||
ASSERT_EQUALS(true, MathLib::isDec("1"));
|
||||
ASSERT_EQUALS(true, MathLib::isDec("+1"));
|
||||
ASSERT_EQUALS(true, MathLib::isDec("-1"));
|
||||
ASSERT_EQUALS(true, MathLib::isDec("-100"));
|
||||
ASSERT_EQUALS(true, MathLib::isDec("-1L"));
|
||||
ASSERT_EQUALS(true, MathLib::isDec("1UL"));
|
||||
|
||||
// negative testing
|
||||
ASSERT_EQUALS(false, MathLib::isDec("-1."));
|
||||
ASSERT_EQUALS(false, MathLib::isDec("+1."));
|
||||
ASSERT_EQUALS(false, MathLib::isDec("-x"));
|
||||
ASSERT_EQUALS(false, MathLib::isDec("+x"));
|
||||
ASSERT_EQUALS(false, MathLib::isDec("x"));
|
||||
}
|
||||
|
||||
void isNullValue() const {
|
||||
// inter zero value
|
||||
|
|
Loading…
Reference in New Issue