diff options
author | Edward Thomson <ethomson@microsoft.com> | 2014-03-07 00:28:18 -0800 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2014-03-07 00:28:18 -0800 |
commit | 806571f3523d64be51e541705da580f28ea8f9a9 (patch) | |
tree | b0825202dee511ae7caa64cbb87c7054fba8a2e6 /tests/clar.c | |
parent | 8e5247203720de7abd084996c00afd6fb6f6cc21 (diff) | |
download | libgit2-806571f3523d64be51e541705da580f28ea8f9a9.tar.gz |
Update clar to a0b00f0
Diffstat (limited to 'tests/clar.c')
-rw-r--r-- | tests/clar.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/clar.c b/tests/clar.c index 6c7399a54..90aeb571d 100644 --- a/tests/clar.c +++ b/tests/clar.c @@ -65,7 +65,12 @@ # ifndef PRIxZ # define PRIxZ "Ix" # endif + +# ifdef _MSC_VER + typedef struct stat STAT_T; +# else typedef struct _stat STAT_T; +# endif #else # include <sys/wait.h> /* waitpid(2) */ # include <unistd.h> @@ -468,6 +473,24 @@ void clar__assert_equal( } } } + else if(!strcmp("%.*s", fmt)) { + const char *s1 = va_arg(args, const char *); + const char *s2 = va_arg(args, const char *); + size_t len = va_arg(args, size_t); + is_equal = (!s1 || !s2) ? (s1 == s2) : !strncmp(s1, s2, len); + + if (!is_equal) { + if (s1 && s2) { + size_t pos; + for (pos = 0; s1[pos] == s2[pos] && pos < len; ++pos) + /* find differing byte offset */; + p_snprintf(buf, sizeof(buf), "'%.*s' != '%.*s' (at byte %d)", + len, s1, len, s2, pos); + } else { + p_snprintf(buf, sizeof(buf), "'%.*s' != '%.*s'", len, s1, len, s2); + } + } + } else if (!strcmp("%"PRIuZ, fmt) || !strcmp("%"PRIxZ, fmt)) { size_t sz1 = va_arg(args, size_t), sz2 = va_arg(args, size_t); is_equal = (sz1 == sz2); |