From 16d24be752482eb46b0d89eb69a15594d47bf3d5 Mon Sep 17 00:00:00 2001 From: "tg(x)" <*@tg-x.net> Date: Mon, 25 Apr 2011 22:31:21 +0200 Subject: [PATCH] added assert for render, removed LPC assert --- include/psyc/debug.h | 16 +--------------- include/psyc/lib.h | 1 + src/render.c | 3 +++ test/testRender.c | 2 +- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/psyc/debug.h b/include/psyc/debug.h index 6ddec4c..986dfc0 100644 --- a/include/psyc/debug.h +++ b/include/psyc/debug.h @@ -3,7 +3,7 @@ #ifdef DEBUG # include -# define PP(args) printf args; +# define PP(args) printf(args); #else # define PP(args) #endif @@ -82,18 +82,4 @@ # define P4(MSG) #endif -// ASSERT() unused as yet -#if DEBUG > 0 -# ifdef STRICT -# define ASSERT(NAME,COND,VALUE) { unless (COND) { \ - PP(("Assertion %s failed in %s: %s\n", NAME, ME, VALUE)); \ - raise_error("Assertion failed (strict mode).\n"); } } -# else -# define ASSERT(NAME,COND,VALUE) { unless (COND) \ - PP(("Assertion %s failed in %s: %s\n", NAME, ME, VALUE)); } -# endif -#else -# define ASSERT(NAME,CONDITION,VALUE) -#endif - #endif // DEBUG_H diff --git a/include/psyc/lib.h b/include/psyc/lib.h index 5e22a2c..d04aae2 100644 --- a/include/psyc/lib.h +++ b/include/psyc/lib.h @@ -6,6 +6,7 @@ #include "../psyc.h" #include "./debug.h" #include +#include /* perlisms for readability */ #define unless(COND) if (!(COND)) diff --git a/src/render.c b/src/render.c index ac31c70..7da3114 100644 --- a/src/render.c +++ b/src/render.c @@ -58,6 +58,9 @@ PSYC_RenderRC PSYC_render(PSYC_Packet *packet, char *buffer, size_t buflen) } memcpy(buffer + cur, PSYC_PACKET_DELIMITER + 1, 2); + cur += 2; + + assert(cur == packet->length); return PSYC_RENDER_SUCCESS; } diff --git a/test/testRender.c b/test/testRender.c index a2f87a1..657f249 100644 --- a/test/testRender.c +++ b/test/testRender.c @@ -12,7 +12,7 @@ int writePresence(const char *avail, int availlen, const char *desc, int desclen PSYC_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_source"), PSYC_C2ARG(myUNI), PSYC_MODIFIER_ROUTING), PSYC_newModifier2(C_GLYPH_OPERATOR_SET, PSYC_C2ARG("_context"), PSYC_C2ARG(myUNI), - PSYC_MODIFIER_CHECK_LENGTH), + PSYC_MODIFIER_ROUTING), }; PSYC_Modifier entity[] = {