X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=blobdiff_plain;f=test%2Fsuites%2Fapi%2Futil.h;h=83be721c3c10aa35f243744c76767b6a63628387;hp=986ef2eda4672900238063733b9d513e900cddd1;hb=58f9d655358bc0c68bfadbc2946b964c2ac774b7;hpb=a33c3628da8434d91609574f7d07f3c90bb8fe00 diff --git a/test/suites/api/util.h b/test/suites/api/util.h index 986ef2e..83be721 100644 --- a/test/suites/api/util.h +++ b/test/suites/api/util.h @@ -5,16 +5,51 @@ * it under the terms of the MIT license. See LICENSE for details. */ -#ifndef TESTPROGS_UTIL_H -#define TESTPROGS_UTIL_H +#ifndef UTIL_H +#define UTIL_H +#include #include +#include + +#define failhdr fprintf(stderr, "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__) #define fail(msg) \ do { \ - fprintf(stderr, "%s:%s:%d: %s\n", \ - __FILE__, __FUNCTION__, __LINE__, msg); \ + failhdr; \ + fprintf(stderr, "%s\n", msg); \ exit(1); \ } while(0) +/* Assumes json_error_t error */ +#define check_error(text_, source_, line_, column_, position_) \ + do { \ + if(strcmp(error.text, text_) != 0) { \ + failhdr; \ + fprintf(stderr, "text: \"%s\" != \"%s\"\n", error.text, text_); \ + exit(1); \ + } \ + if(strcmp(error.source, source_) != 0) { \ + failhdr; \ + \ + fprintf(stderr, "source: \"%s\" != \"%s\"\n", error.source, source_); \ + exit(1); \ + } \ + if(error.line != line_) { \ + failhdr; \ + fprintf(stderr, "line: %d != %d\n", error.line, line_); \ + exit(1); \ + } \ + if(error.column != column_) { \ + failhdr; \ + fprintf(stderr, "column: %d != %d\n", error.column, column_); \ + exit(1); \ + } \ + if(error.position != position_) { \ + failhdr; \ + fprintf(stderr, "position: %d != %d\n", error.position, position_); \ + exit(1); \ + } \ + } while(0) + #endif