From 8039c7d26c553509afe8b2dce0e9deca28957e9f Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Thu, 15 Oct 2020 17:41:55 -0400 Subject: test: Add test case for doubles --- test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test.c b/test.c index 7e7e1cb..4ec7bfa 100644 --- a/test.c +++ b/test.c @@ -11,6 +11,7 @@ #include #include #include +#include #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) { -- cgit v1.2.3