Commit 21a1207a authored by Daniel Melani's avatar Daniel Melani
Browse files

Add tests for redisFree() and freeReplyObject()

Test that redisFree() and freeReplyObject() do not crash when NULL is
passed in.
parent 05b85ebe
...@@ -318,6 +318,19 @@ static void test_reply_reader(void) { ...@@ -318,6 +318,19 @@ static void test_reply_reader(void) {
redisReaderFree(reader); redisReaderFree(reader);
} }
static void test_free_null(void) {
void *redisContext = NULL;
void *reply = NULL;
test("Don't fail when redisFree is passed a NULL value: ");
redisFree(redisContext);
test_cond(redisContext == NULL);
test("Don't fail when freeReplyObject is passed a NULL value: ");
freeReplyObject(reply);
test_cond(reply == NULL);
}
static void test_blocking_connection_errors(void) { static void test_blocking_connection_errors(void) {
redisContext *c; redisContext *c;
...@@ -702,6 +715,7 @@ int main(int argc, char **argv) { ...@@ -702,6 +715,7 @@ int main(int argc, char **argv) {
test_format_commands(); test_format_commands();
test_reply_reader(); test_reply_reader();
test_blocking_connection_errors(); test_blocking_connection_errors();
test_free_null();
printf("\nTesting against TCP connection (%s:%d):\n", cfg.tcp.host, cfg.tcp.port); printf("\nTesting against TCP connection (%s:%d):\n", cfg.tcp.host, cfg.tcp.port);
cfg.type = CONN_TCP; cfg.type = CONN_TCP;
...@@ -723,6 +737,7 @@ int main(int argc, char **argv) { ...@@ -723,6 +737,7 @@ int main(int argc, char **argv) {
test_blocking_connection(cfg); test_blocking_connection(cfg);
} }
if (fails) { if (fails) {
printf("*** %d TESTS FAILED ***\n", fails); printf("*** %d TESTS FAILED ***\n", fails);
return 1; return 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment