X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fcomparison.hpp;h=63bd08a2118eb5c8485e3a8fef5c6ab4ec2edc09;hb=5d68a7b1d0fff81d547b8a74ad72247437f412c5;hp=2a00284fbddef1a881feaf475c013d02ae72ecc6;hpb=9139975f5fe7895259645117b1e0e9a6cb9c27cc;p=awesomized%2Flibmemcached diff --git a/libtest/comparison.hpp b/libtest/comparison.hpp index 2a00284f..63bd08a2 100644 --- a/libtest/comparison.hpp +++ b/libtest/comparison.hpp @@ -86,6 +86,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) {