[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha2-37-g95a3cf4
git at osgeo.org
git at osgeo.org
Mon Aug 3 03:22:21 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via 95a3cf4c9dcd04977bf2ff1ed700156694a43344 (commit)
from 25825b61d26844c794d7f6c8f47dc3f5458c9c95 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 95a3cf4c9dcd04977bf2ff1ed700156694a43344
Author: Raúl Marín <git at rmr.ninja>
Date: Mon Aug 3 11:42:28 2020 +0200
Rework ASSERT_STRING_EQUAL to not crash on NULL inputs
diff --git a/liblwgeom/Makefile.in b/liblwgeom/Makefile.in
index 03ce001..5470f9a 100644
--- a/liblwgeom/Makefile.in
+++ b/liblwgeom/Makefile.in
@@ -202,6 +202,7 @@ check: check-unit
check-regress:
+.PHONY: check-unit
check-unit: liblwgeom.la
$(MAKE) -C cunit check
diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in
index be2dd97..a228a3d 100644
--- a/liblwgeom/cunit/Makefile.in
+++ b/liblwgeom/cunit/Makefile.in
@@ -89,13 +89,14 @@ else
all: cu_tester
# Build and run the unit tester
+.PHONY: check
check: cu_tester
$(LIBTOOL) --mode=execute $(LIBTOOL_VALGRIND) ./cu_tester
endif
# Build the main unit test executable
-cu_tester: ../liblwgeom.la $(OBJS)
+cu_tester: ../liblwgeom.la $(OBJS) cu_tester.h
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) -static ../liblwgeom.la
# Command to build each of the .o files
diff --git a/liblwgeom/cunit/cu_tester.h b/liblwgeom/cunit/cu_tester.h
index baa5e62..6c253d5 100644
--- a/liblwgeom/cunit/cu_tester.h
+++ b/liblwgeom/cunit/cu_tester.h
@@ -14,6 +14,7 @@
#define _CU_TESTER_H 1
#include "liblwgeom.h"
+#include <stdio.h>
#define MAX_CUNIT_ERROR_LENGTH 512
@@ -40,11 +41,25 @@ typedef void (*PG_SuiteSetup)(void);
CU_ASSERT_EQUAL(o,e); \
} while (0);
-#define ASSERT_STRING_EQUAL(o,e) do { \
- if ( strcmp(o,e) != 0 ) \
- fprintf(stderr, "[%s:%d]\n Expected: %s\n Obtained: %s\n", __FILE__, __LINE__, (e), (o)); \
- CU_ASSERT_STRING_EQUAL(o,e); \
-} while (0);
+static inline void
+assert_string_equal_impl(const char *obtained, const char *expected, const char *file, int line)
+{
+ CU_BOOL error = (!obtained && expected) || (obtained && !expected) || (strcmp(obtained, expected) != 0);
+ char *msg = NULL;
+ if (error)
+ {
+ msg = lwalloc(60 + (obtained ? strlen(obtained) : 4) + (expected ? strlen(expected) : 4));
+ sprintf(msg,
+ "ASSERT_STRING_EQUAL\n\t* Expected: %s\n\t* Obtained: %s",
+ expected ? expected : "NULL",
+ obtained ? obtained : "NULL");
+ }
+ CU_assertImplementation(!error, line, msg, file, NULL, CU_FALSE);
+ if (msg)
+ lwfree(msg);
+}
+
+#define ASSERT_STRING_EQUAL(o, e) assert_string_equal_impl(o, e, __FILE__, __LINE__)
#define ASSERT_VARLENA_EQUAL(v, s) \
do \
-----------------------------------------------------------------------
Summary of changes:
liblwgeom/Makefile.in | 1 +
liblwgeom/cunit/Makefile.in | 3 ++-
liblwgeom/cunit/cu_tester.h | 25 ++++++++++++++++++++-----
3 files changed, 23 insertions(+), 6 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list