diff options
author | Alex Smith <aes7mv@virginia.edu> | 2020-10-15 17:41:55 -0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2021-02-25 21:25:17 -0800 |
commit | 8039c7d26c553509afe8b2dce0e9deca28957e9f (patch) | |
tree | e0dd44e06c1b9ffbe9681dfd7fba106e5bc92eac /test.c | |
parent | 49539fd1a74bef7f0646565adad9deaead2b1664 (diff) |
test: Add test case for doubles
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -11,6 +11,7 @@ #include <signal.h> #include <errno.h> #include <limits.h> +#include <math.h> #include "hiredis.h" #include "async.h" @@ -583,6 +584,18 @@ static void test_reply_reader(void) { ((redisReply*)reply)->element[1]->integer == 42); freeReplyObject(reply); redisReaderFree(reader); + + test("Can parse RESP3 doubles: "); + reader = redisReaderCreate(); + redisReaderFeed(reader, ",3.14159265358979323846\r\n",25); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_DOUBLE && + fabs(((redisReply*)reply)->dval - 3.14159265358979323846) < 0.00000001 && + ((redisReply*)reply)->len == 22 && + strcmp(((redisReply*)reply)->str, "3.14159265358979323846") == 0); + freeReplyObject(reply); + redisReaderFree(reader); } static void test_free_null(void) { |