Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
bb2d0911
Commit
bb2d0911
authored
Sep 30, 2011
by
Pieter Noordhuis
Browse files
Move custom asserts to test helper
parent
c288dd29
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/test-helper.h
0 → 100644
View file @
bb2d0911
#ifndef _TEST_HELPER_H
#define _TEST_HELPER_H 1
#include <stdio.h>
#include <assert.h>
#define assert_equal(a, b, type, fmt) do { \
type a_ = (a); \
type b_ = (b); \
if (a_ != b_) { \
fprintf(stderr, \
"%s:%d: " fmt " != " fmt "\n", \
__FILE__, __LINE__, a_, b_); \
assert(0); \
} \
} while(0)
#define assert_equal_int(a,b) do { \
assert_equal(a, b, int, "%d"); \
} while(0)
#define assert_equal_size_t(a,b) do { \
assert_equal(a, b, size_t, "%lu"); \
} while(0)
/* Use long long to avoid compiler warnings about the printf format. */
#define assert_equal_int64_t(a,b) do { \
assert_equal(a, b, long long, "%lld"); \
} while(0)
#define assert_equal_double(a,b) do { \
assert_equal(a, b, double, "%f"); \
} while(0)
#endif
test/test-parser.c
View file @
bb2d0911
...
@@ -4,41 +4,13 @@
...
@@ -4,41 +4,13 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
/* local */
/* local */
#include "test-helper.h"
#include "../parser.h"
#include "../parser.h"
#include "../sds.h"
#include "../sds.h"
#define assert_equal(a, b, type, fmt) do { \
type a_ = (a); \
type b_ = (b); \
if (a_ != b_) { \
fprintf(stderr, \
"%s:%d: " fmt " != " fmt "\n", \
__FILE__, __LINE__, a_, b_); \
assert(0); \
} \
} while(0)
#define assert_equal_int(a,b) do { \
assert_equal(a, b, int, "%d"); \
} while(0)
#define assert_equal_size_t(a,b) do { \
assert_equal(a, b, size_t, "%lu"); \
} while(0)
/* Use long long to avoid compiler warnings about the printf format. */
#define assert_equal_int64_t(a,b) do { \
assert_equal(a, b, long long, "%lld"); \
} while(0)
#define assert_equal_double(a,b) do { \
assert_equal(a, b, double, "%f"); \
} while(0)
typedef
struct
log_entry_s
log_entry_t
;
typedef
struct
log_entry_s
log_entry_t
;
struct
log_entry_s
{
struct
log_entry_s
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment