diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-04-21 16:03:54 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-04-21 16:03:54 +0200 |
commit | 19709152f2a4d43de0d1c93b2a231f1464de3b24 (patch) | |
tree | d316581ee35149d57056c336b035801e62d96fe8 | |
parent | 965d42640f2f707ca103edeb758bde83ca8cfe9b (diff) |
Reflect rename in tests
-rw-r--r-- | test.c | 70 |
1 files changed, 33 insertions, 37 deletions
@@ -270,68 +270,64 @@ static void test_blocking_connection(void) { static void test_reply_reader(void) { redisReader *reader; void *reply; - char *err; int ret; test("Error handling in reply parser: "); - reader = redisReplyReaderCreate(); - redisReplyReaderFeed(reader,(char*)"@foo\r\n",6); - ret = redisReplyReaderGetReply(reader,NULL); - err = redisReplyReaderGetError(reader); + reader = redisReaderCreate(); + redisReaderFeed(reader,(char*)"@foo\r\n",6); + ret = redisReaderGetReply(reader,NULL); test_cond(ret == REDIS_ERR && - strcasecmp(err,"Protocol error, got \"@\" as reply type byte") == 0); - redisReplyReaderFree(reader); + strcasecmp(reader->errstr,"Protocol error, got \"@\" as reply type byte") == 0); + redisReaderFree(reader); /* when the reply already contains multiple items, they must be free'd * on an error. valgrind will bark when this doesn't happen. */ test("Memory cleanup in reply parser: "); - reader = redisReplyReaderCreate(); - redisReplyReaderFeed(reader,(char*)"*2\r\n",4); - redisReplyReaderFeed(reader,(char*)"$5\r\nhello\r\n",11); - redisReplyReaderFeed(reader,(char*)"@foo\r\n",6); - ret = redisReplyReaderGetReply(reader,NULL); - err = redisReplyReaderGetError(reader); + reader = redisReaderCreate(); + redisReaderFeed(reader,(char*)"*2\r\n",4); + redisReaderFeed(reader,(char*)"$5\r\nhello\r\n",11); + redisReaderFeed(reader,(char*)"@foo\r\n",6); + ret = redisReaderGetReply(reader,NULL); test_cond(ret == REDIS_ERR && - strcasecmp(err,"Protocol error, got \"@\" as reply type byte") == 0); - redisReplyReaderFree(reader); + strcasecmp(reader->errstr,"Protocol error, got \"@\" as reply type byte") == 0); + redisReaderFree(reader); test("Set error on nested multi bulks with depth > 1: "); - reader = redisReplyReaderCreate(); - redisReplyReaderFeed(reader,(char*)"*1\r\n",4); - redisReplyReaderFeed(reader,(char*)"*1\r\n",4); - redisReplyReaderFeed(reader,(char*)"*1\r\n",4); - ret = redisReplyReaderGetReply(reader,NULL); - err = redisReplyReaderGetError(reader); + reader = redisReaderCreate(); + redisReaderFeed(reader,(char*)"*1\r\n",4); + redisReaderFeed(reader,(char*)"*1\r\n",4); + redisReaderFeed(reader,(char*)"*1\r\n",4); + ret = redisReaderGetReply(reader,NULL); test_cond(ret == REDIS_ERR && - strncasecmp(err,"No support for",14) == 0); - redisReplyReaderFree(reader); + strncasecmp(reader->errstr,"No support for",14) == 0); + redisReaderFree(reader); test("Works with NULL functions for reply: "); - reader = redisReplyReaderCreate(); + reader = redisReaderCreate(); reader->fn = NULL; - redisReplyReaderFeed(reader,(char*)"+OK\r\n",5); - ret = redisReplyReaderGetReply(reader,&reply); + redisReaderFeed(reader,(char*)"+OK\r\n",5); + ret = redisReaderGetReply(reader,&reply); test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS); - redisReplyReaderFree(reader); + redisReaderFree(reader); test("Works when a single newline (\\r\\n) covers two calls to feed: "); - reader = redisReplyReaderCreate(); + reader = redisReaderCreate(); reader->fn = NULL; - redisReplyReaderFeed(reader,(char*)"+OK\r",4); - ret = redisReplyReaderGetReply(reader,&reply); + redisReaderFeed(reader,(char*)"+OK\r",4); + ret = redisReaderGetReply(reader,&reply); assert(ret == REDIS_OK && reply == NULL); - redisReplyReaderFeed(reader,(char*)"\n",1); - ret = redisReplyReaderGetReply(reader,&reply); + redisReaderFeed(reader,(char*)"\n",1); + ret = redisReaderGetReply(reader,&reply); test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS); - redisReplyReaderFree(reader); + redisReaderFree(reader); test("Don't reset state after protocol error: "); - reader = redisReplyReaderCreate(); + reader = redisReaderCreate(); reader->fn = NULL; - redisReplyReaderFeed(reader,(char*)"x",1); - ret = redisReplyReaderGetReply(reader,&reply); + redisReaderFeed(reader,(char*)"x",1); + ret = redisReaderGetReply(reader,&reply); assert(ret == REDIS_ERR); - ret = redisReplyReaderGetReply(reader,&reply); + ret = redisReaderGetReply(reader,&reply); test_cond(ret == REDIS_ERR && reply == NULL); } |