Skip to content

Commit

Permalink
Resolving CxxTest#122 "C string DIFFERS not consistent with EQUALS"
Browse files Browse the repository at this point in the history
New specialized templates for the differs test
to manage C strings, as done for equals
(cf. CxxTest#82, CxxTest#83 & CxxTest#84).
  • Loading branch information
Oliviers-OSS committed Aug 5, 2015
1 parent 774ebb6 commit 3822aca
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions cxxtest/TestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,70 @@ struct differs
}
};

template<>
struct differs<const char*, const char*>
{
static bool test(const char *x, const char *y)
{
if ((x != 0) && (y != 0))
{
return (CXXTEST_STD(strcmp(x, y)) != 0);
}
else
{
return (x != y);
}
}
};

template<>
struct differs<char*, char*>
{
static bool test(char *x, char *y)
{
if ((x != 0) && (y != 0))
{
return (CXXTEST_STD(strcmp(x, y)) != 0);
}
else
{
return (x != y);
}
}
};

template<>
struct differs<const char*, char*>
{
static bool test(const char *x, char *y)
{
if ((x != 0) && (y != 0))
{
return (CXXTEST_STD(strcmp(x, y)) != 0);
}
else
{
return (x != y);
}
}
};

template<>
struct differs<char*, const char*>
{
static bool test(char *x, const char *y)
{
if ((x != 0) && (y != 0))
{
return (CXXTEST_STD(strcmp(x, y)) != 0);
}
else
{
return (x != y);
}
}
};

template<class X, class Y>
void doAssertDiffers(const char *file, int line,
const char *xExpr, X x,
Expand Down

0 comments on commit 3822aca

Please sign in to comment.