Skip to content

Commit 95b492d

Browse files
apply C++ compatability for string assertions
1 parent 0401f8e commit 95b492d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

code/logic/fossil/test/assume.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,53 +2177,83 @@ extern "C" {
21772177
* @param actual The actual byte string.
21782178
* @param expected The expected byte string.
21792179
*/
2180+
#ifdef __cplusplus
2181+
#define ASSUME_ITS_EQUAL_BSTR(actual, expected) \
2182+
FOSSIL_TEST_ASSUME(strcmp((const char*)(actual.c_str()), (const char*)(expected.c_str())) == 0, "Expected byte string " #actual " to be equal to " #expected)
2183+
#else
21802184
#define ASSUME_ITS_EQUAL_BSTR(actual, expected) \
21812185
FOSSIL_TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) == 0, "Expected byte string " #actual " to be equal to " #expected)
2186+
#endif
21822187

21832188
/**
21842189
* @brief Assumes that the given byte strings are not equal.
21852190
*
21862191
* @param actual The actual byte string.
21872192
* @param expected The expected byte string.
21882193
*/
2194+
#ifdef __cplusplus
2195+
#define ASSUME_NOT_EQUAL_BSTR(actual, expected) \
2196+
FOSSIL_TEST_ASSUME(strcmp((const char*)(actual.c_str()), (const char*)(expected.c_str())) != 0, "Expected byte string " #actual " to not be equal to " #expected)
2197+
#else
21892198
#define ASSUME_NOT_EQUAL_BSTR(actual, expected) \
21902199
FOSSIL_TEST_ASSUME(strcmp((const char*)(actual), (const char*)(expected)) != 0, "Expected byte string " #actual " to not be equal to " #expected)
2200+
#endif
21912201

21922202
/**
21932203
* @brief Assumes that the length of the given byte string is equal to the expected length.
21942204
*
21952205
* @param actual The actual byte string.
21962206
* @param expected_len The expected length of the byte string.
21972207
*/
2208+
#ifdef __cplusplus
2209+
#define ASSUME_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \
2210+
FOSSIL_TEST_ASSUME(strlen((const char*)(actual.c_str())) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len)
2211+
#else
21982212
#define ASSUME_ITS_LENGTH_EQUAL_BSTR(actual, expected_len) \
21992213
FOSSIL_TEST_ASSUME(strlen((const char*)(actual)) == (expected_len), "Expected length of byte string " #actual " to be equal to " #expected_len)
2214+
#endif
22002215

22012216
/**
22022217
* @brief Assumes that the given C strings are equal.
22032218
*
22042219
* @param actual The actual C string.
22052220
* @param expected The expected C string.
22062221
*/
2222+
#ifdef __cplusplus
2223+
#define ASSUME_ITS_EQUAL_CSTR(actual, expected) \
2224+
FOSSIL_TEST_ASSUME(strcmp((actual.c_str()), (expected.c_str())) == 0, "Expected C string " #actual " to be equal to " #expected)
2225+
#else
22072226
#define ASSUME_ITS_EQUAL_CSTR(actual, expected) \
22082227
FOSSIL_TEST_ASSUME(strcmp((actual), (expected)) == 0, "Expected C string " #actual " to be equal to " #expected)
2228+
#endif
22092229

22102230
/**
22112231
* @brief Assumes that the given C strings are not equal.
22122232
*
22132233
* @param actual The actual C string.
22142234
* @param expected The expected C string.
22152235
*/
2236+
#ifdef __cplusplus
2237+
#define ASSUME_NOT_EQUAL_CSTR(actual, expected) \
2238+
FOSSIL_TEST_ASSUME(strcmp((actual.c_str()), (expected.c_str())) != 0, "Expected C string " #actual " to not be equal to " #expected)
2239+
#else
22162240
#define ASSUME_NOT_EQUAL_CSTR(actual, expected) \
22172241
FOSSIL_TEST_ASSUME(strcmp((actual), (expected)) != 0, "Expected C string " #actual " to not be equal to " #expected)
2242+
#endif
22182243

22192244
/**
22202245
* @brief Assumes that the length of the given C string is equal to the expected length.
22212246
*
22222247
* @param actual The actual C string.
22232248
* @param expected_len The expected length of the C string.
22242249
*/
2250+
#ifdef __cplusplus
2251+
#define ASSUME_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \
2252+
FOSSIL_TEST_ASSUME(strlen((actual.c_str())) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len)
2253+
#else
22252254
#define ASSUME_ITS_LENGTH_EQUAL_CSTR(actual, expected_len) \
22262255
FOSSIL_TEST_ASSUME(strlen((actual)) == (expected_len), "Expected length of C string " #actual " to be equal to " #expected_len)
2256+
#endif
22272257

22282258
#ifdef __cplusplus
22292259
}

0 commit comments

Comments
 (0)