diff options
author | Alex Smith <aes7mv@virginia.edu> | 2020-10-15 17:50:49 -0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2021-02-25 21:25:17 -0800 |
commit | 96e8ea611022e8c360f1883b81f6ec2a386b9ed3 (patch) | |
tree | d6d12f934bc549f5bd3a4f2ce653fc0ef0a1f97e | |
parent | f913e9b997e2cc4b847923e1b3b0649d77c85923 (diff) |
test: Add test cases for infinite and NaN doubles
-rw-r--r-- | test.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -596,6 +596,26 @@ static void test_reply_reader(void) { strcmp(((redisReply*)reply)->str, "3.14159265358979323846") == 0); freeReplyObject(reply); redisReaderFree(reader); + + test("Correctly parses RESP3 double INFINITY: "); + reader = redisReaderCreate(); + redisReaderFeed(reader, ",inf\r\n",6); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_DOUBLE && + isinf(((redisReply*)reply)->dval) && + ((redisReply*)reply)->dval > 0); + freeReplyObject(reply); + redisReaderFree(reader); + + test("Set error when RESP3 double is NaN: "); + reader = redisReaderCreate(); + redisReaderFeed(reader, ",nan\r\n",6); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_ERR && + strcasecmp(reader->errstr,"Bad double value") == 0); + freeReplyObject(reply); + redisReaderFree(reader); } static void test_free_null(void) { |