aboutsummaryrefslogtreecommitdiff
path: root/test/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/util.cpp')
-rw-r--r--test/util.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/util.cpp b/test/util.cpp
new file mode 100644
index 0000000..e90882a
--- /dev/null
+++ b/test/util.cpp
@@ -0,0 +1,15 @@
+#include <gtest/gtest.h>
+
+#include "backend/util.h"
+
+TEST(Util, SafeFree) {
+ char * str = static_cast<char *>(malloc(3));
+ ASSERT_NE(str, nullptr);
+
+ safe_free(&str);
+ ASSERT_EQ(str, nullptr);
+
+ // this shouldn't cause double free() error:
+ safe_free(&str);
+}
+