* Fixed assert_*() macros so they no longer truncate values to int.
authorstewartamiles <stewartamiles@40f4469a-5155-0410-be90-2de3f0bae501>
Fri, 28 Aug 2009 15:37:04 +0000 (15:37 +0000)
committerstewartamiles <stewartamiles@40f4469a-5155-0410-be90-2de3f0bae501>
Fri, 28 Aug 2009 15:37:04 +0000 (15:37 +0000)
* Fixed printf format specifier for unsigned long long.
* Worked around a 64-bit gcc warning when casting a 32-bit integer to
  a pointer in the expect_assert_failure() macro.

git-svn-id: http://cmockery.googlecode.com/svn/trunk@42 40f4469a-5155-0410-be90-2de3f0bae501

src/cmockery.c
src/google/cmockery.h

index e7ad3b17bff692cf9af70e05072e11578e03a5d6..df78ea29c86dbaf05e52d08b595404d723561799 100755 (executable)
@@ -1220,7 +1220,8 @@ void mock_assert(const int result, const char* const expression,
 }
 
 
-void _assert_true(const int result, const char * const expression,
+void _assert_true(const LargestIntegralType result,
+                  const char * const expression,
                   const char * const file, const int line) {
     if (!result) {
         print_error("%s\n", expression);
index ec47e587045f53e55b6a095f42dd0dab08440512..c237f0139bf7628b1dfe2020a4dca2d2268f1f33 100755 (executable)
 
 // Printf format used to display LargestIntegralType.
 #ifndef LargestIntegralTypePrintfFormat
-#define LargestIntegralTypePrintfFormat "%lx"
+#ifdef _WIN32
+#define LargestIntegralTypePrintfFormat "%I64x"
+#else
+#define LargestIntegralTypePrintfFormat "%llx"
+#endif // _WIN32
 #endif // LargestIntegralTypePrintfFormat
 
 // Perform an unsigned cast to LargestIntegralType.
                     cast_to_largest_integral_type(parameter))
 
 // Assert that the given expression is true.
-#define assert_true(c) _assert_true((int)(c), #c, __FILE__, __LINE__)
+#define assert_true(c) _assert_true(cast_to_largest_integral_type(c), #c, \
+                                    __FILE__, __LINE__)
 // Assert that the given expression is false.
-#define assert_false(c) _assert_true(!((int)(c)), #c, __FILE__, __LINE__)
+#define assert_false(c) _assert_true(!(cast_to_largest_integral_type(c)), #c, \
+                                     __FILE__, __LINE__)
 
 // Assert that the two given integers are equal, otherwise fail.
 #define assert_int_equal(a, b) \
  */
 #define expect_assert_failure(function_call) \
   { \
-    const char* expression = (const char*)setjmp(global_expect_assert_env); \
+    const int expression = setjmp(global_expect_assert_env); \
     global_expecting_assert = 1; \
     if (expression) { \
-      print_message("Expected assertion %s occurred\n", expression); \
+      print_message("Expected assertion %s occurred\n", \
+                    *((const char**)&expression)); \
       global_expecting_assert = 0; \
     } else { \
       function_call ; \
@@ -424,7 +431,8 @@ void mock_assert(const int result, const char* const expression,
 void _will_return(const char * const function_name, const char * const file,
                   const int line, const LargestIntegralType value,
                   const int count);
-void _assert_true(const int result, const char* const expression,
+void _assert_true(const LargestIntegralType result,
+                  const char* const expression,
                   const char * const file, const int line);
 void _assert_int_equal(
     const LargestIntegralType a, const LargestIntegralType b,