X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fcomparison.hpp;h=aecf05f0c694632224e2adb4f9e8fa1bdb414b77;hb=1d3ffcb8031a12f06404a0700d556901b773c409;hp=2a00284fbddef1a881feaf475c013d02ae72ecc6;hpb=a1f2b0b98e03369ed051b232f1fc33ed1d611b16;p=m6w6%2Flibmemcached diff --git a/libtest/comparison.hpp b/libtest/comparison.hpp index 2a00284f..aecf05f0 100644 --- a/libtest/comparison.hpp +++ b/libtest/comparison.hpp @@ -41,6 +41,7 @@ #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED #include #include +#include #endif #if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN @@ -86,6 +87,29 @@ bool _compare(const char *file, int line, const char *func, const T1_comparable& return true; } +template +bool _compare_strcmp(const char *file, int line, const char *func, const T1_comparable& __expected, const T2_comparable& __actual) +{ + if (__expected == NULL) + { + fatal_message("Expected value was NULL, programmer error"); + } + + if (__actual == NULL) + { + libtest::stream::make_cerr(file, line, func) << "Expected " << __expected << " but got NULL"; + return false; + } + + if (strncmp(__expected, __actual, strlen(__expected))) + { + libtest::stream::make_cerr(file, line, func) << "Expected " << __expected << " passed \"" << __actual << "\""; + return false; + } + + return true; +} + template bool _compare_zero(const char *file, int line, const char *func, T_comparable __actual) {