/*
 * Copyright (c) 2015 Paul Fariello <paul@fariello.eu>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _ck_assert_ptr
/* Pointer comparsion macros with improved output compared to fail_unless(). */
/* OP may be any comparion operator. */
#define _ck_assert_ptr(X, OP, Y) do { \
  void *_ck_x = (X); \
  void *_ck_y = (Y); \
  ck_assert_msg(_ck_x OP _ck_y, "Assertion '"#X#OP#Y"' failed: "#X"==%p, "#Y"==%p", _ck_x, _ck_y); \
} while (0)
#endif

#ifndef ck_assert_ptr_eq
#define ck_assert_ptr_eq(X, Y) _ck_assert_ptr(X, ==, Y)
#endif /* ck_assert_ptr_eq */

#ifndef ck_assert_ptr_ne
#define ck_assert_ptr_ne(X, Y) _ck_assert_ptr(X, !=, Y)
#endif /* ck_assert_ptr_ne */

#ifndef ck_assert_ptr_lt
#define ck_assert_ptr_lt(X, Y) _ck_assert_ptr(X, <, Y)
#endif /* ck_assert_ptr_lt */

#ifndef ck_assert_ptr_le
#define ck_assert_ptr_le(X, Y) _ck_assert_ptr(X, <=, Y)
#endif /* ck_assert_ptr_le */

#ifndef ck_assert_ptr_gt
#define ck_assert_ptr_gt(X, Y) _ck_assert_ptr(X, >, Y)
#endif /* ck_assert_ptr_gt */

#ifndef ck_assert_ptr_ge
#define ck_assert_ptr_ge(X, Y) _ck_assert_ptr(X, >=, Y)
#endif /* ck_assert_ptr_ge */

#ifndef ck_assert_int_gt
#define ck_assert_int_gt(X, Y) _ck_assert_int(X, >, Y)
#endif /* ck_assert_int_gt */
