1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include <cxxtest/TestSuite.h>
//
// A test for issue 122/123, where TS_ASSERT_EQUALS and TS_ASSERT_DIFFERS were
// both true at the same time.
//
// not const on purpose
static char non_const_value_1[] = { "toto" };
static char non_const_value_2[] = { "toto" }; // different pointers from value1
static char non_const_value_3[] = { "nekobus" };
class CharAssertions : public CxxTest::TestSuite {
public:
template <typename T1, typename T2> void differs_must_succeed_generator()
{
T1 str1 = non_const_value_1;
T2 str2 = non_const_value_3;
TS_ASSERT_DIFFERS(str1, str2);
}
template <typename T1, typename T2> void differs_must_fail_generator()
{
T1 str1 = non_const_value_1;
T2 str2 = non_const_value_2;
TS_ASSERT_DIFFERS(str1, str2);
}
template <typename T1, typename T2> void equals_must_succeed_generator()
{
T1 str1 = non_const_value_1;
T2 str2 = non_const_value_2;
TS_ASSERT_EQUALS(str1, str2);
}
template <typename T1, typename T2> void equals_must_fail_generator()
{
T1 str1 = non_const_value_1;
T2 str2 = non_const_value_3;
TS_ASSERT_EQUALS(str1, str2);
}
// we must test the entire matrix
// naming scheme is test_[de][sf][cm][cm], where:
// - d or e are for 'differs' and 'equals'
// - s or f are for 'expect to succeed' or 'expect to fail'
// - c or m are for 'const' or 'mutable' chars.
void test_dscc()
{
differs_must_succeed_generator<char const* const, char const* const>();
}
void test_dscm()
{
differs_must_succeed_generator<char const* const, char const*>();
}
void test_dsmc()
{
differs_must_succeed_generator<char const*, char const* const>();
}
void test_dsmm()
{
differs_must_succeed_generator<char const*, char const*>();
}
void test_dfcc()
{
differs_must_fail_generator<char const* const, char const* const>();
}
void test_dfcm()
{
differs_must_fail_generator<char const* const, char const*>();
}
void test_dfmc()
{
differs_must_fail_generator<char const*, char const* const>();
}
void test_dfmm()
{
differs_must_fail_generator<char const*, char const*>();
}
void test_escc()
{
equals_must_succeed_generator<char const* const, char const* const>();
}
void test_escm()
{
equals_must_succeed_generator<char const* const, char const*>();
}
void test_esmc()
{
equals_must_succeed_generator<char const*, char const* const>();
}
void test_esmm()
{
equals_must_succeed_generator<char const*, char const*>();
}
void test_efcc()
{
equals_must_fail_generator<char const* const, char const* const>();
}
void test_efcm()
{
equals_must_fail_generator<char const* const, char const*>();
}
void test_efmc()
{
equals_must_fail_generator<char const*, char const* const>();
}
void test_efmm()
{
equals_must_fail_generator<char const*, char const*>();
}
};
|