diff options
author | Alex Smith <aes7mv@virginia.edu> | 2020-10-15 18:18:20 -0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2021-02-25 21:25:17 -0800 |
commit | 81c48a9821e3350191ed6a1e0a3ed575d75df35d (patch) | |
tree | 66928f476e3a70bb084843a3d5e67878dd8f486c /test.c | |
parent | 51e693f4fd54d6a9dfbdafa1b361f6618e4f7ba3 (diff) |
test: Add test cases for RESP3 bool
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -634,6 +634,35 @@ static void test_reply_reader(void) { strcasecmp(reader->errstr,"Bad nil value") == 0); freeReplyObject(reply); redisReaderFree(reader); + + test("Can parse RESP3 bool (true): "); + reader = redisReaderCreate(); + redisReaderFeed(reader, "#t\r\n",4); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_BOOL && + ((redisReply*)reply)->integer); + freeReplyObject(reply); + redisReaderFree(reader); + + test("Can parse RESP3 bool (false): "); + reader = redisReaderCreate(); + redisReaderFeed(reader, "#f\r\n",4); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_BOOL && + !((redisReply*)reply)->integer); + freeReplyObject(reply); + redisReaderFree(reader); + + test("Set error on invalid RESP3 bool: "); + reader = redisReaderCreate(); + redisReaderFeed(reader, "#foobar\r\n",9); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_ERR && + strcasecmp(reader->errstr,"Bad bool value") == 0); + freeReplyObject(reply); + redisReaderFree(reader); } static void test_free_null(void) { |