Reflect rename in tests

This commit is contained in:
Pieter Noordhuis 2011-04-21 16:03:54 +02:00
parent 965d42640f
commit 19709152f2

70
test.c
View File

@ -270,68 +270,64 @@ static void test_blocking_connection(void) {
static void test_reply_reader(void) { static void test_reply_reader(void) {
redisReader *reader; redisReader *reader;
void *reply; void *reply;
char *err;
int ret; int ret;
test("Error handling in reply parser: "); test("Error handling in reply parser: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
redisReplyReaderFeed(reader,(char*)"@foo\r\n",6); redisReaderFeed(reader,(char*)"@foo\r\n",6);
ret = redisReplyReaderGetReply(reader,NULL); ret = redisReaderGetReply(reader,NULL);
err = redisReplyReaderGetError(reader);
test_cond(ret == REDIS_ERR && test_cond(ret == REDIS_ERR &&
strcasecmp(err,"Protocol error, got \"@\" as reply type byte") == 0); strcasecmp(reader->errstr,"Protocol error, got \"@\" as reply type byte") == 0);
redisReplyReaderFree(reader); redisReaderFree(reader);
/* when the reply already contains multiple items, they must be free'd /* when the reply already contains multiple items, they must be free'd
* on an error. valgrind will bark when this doesn't happen. */ * on an error. valgrind will bark when this doesn't happen. */
test("Memory cleanup in reply parser: "); test("Memory cleanup in reply parser: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
redisReplyReaderFeed(reader,(char*)"*2\r\n",4); redisReaderFeed(reader,(char*)"*2\r\n",4);
redisReplyReaderFeed(reader,(char*)"$5\r\nhello\r\n",11); redisReaderFeed(reader,(char*)"$5\r\nhello\r\n",11);
redisReplyReaderFeed(reader,(char*)"@foo\r\n",6); redisReaderFeed(reader,(char*)"@foo\r\n",6);
ret = redisReplyReaderGetReply(reader,NULL); ret = redisReaderGetReply(reader,NULL);
err = redisReplyReaderGetError(reader);
test_cond(ret == REDIS_ERR && test_cond(ret == REDIS_ERR &&
strcasecmp(err,"Protocol error, got \"@\" as reply type byte") == 0); strcasecmp(reader->errstr,"Protocol error, got \"@\" as reply type byte") == 0);
redisReplyReaderFree(reader); redisReaderFree(reader);
test("Set error on nested multi bulks with depth > 1: "); test("Set error on nested multi bulks with depth > 1: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
redisReplyReaderFeed(reader,(char*)"*1\r\n",4); redisReaderFeed(reader,(char*)"*1\r\n",4);
redisReplyReaderFeed(reader,(char*)"*1\r\n",4); redisReaderFeed(reader,(char*)"*1\r\n",4);
redisReplyReaderFeed(reader,(char*)"*1\r\n",4); redisReaderFeed(reader,(char*)"*1\r\n",4);
ret = redisReplyReaderGetReply(reader,NULL); ret = redisReaderGetReply(reader,NULL);
err = redisReplyReaderGetError(reader);
test_cond(ret == REDIS_ERR && test_cond(ret == REDIS_ERR &&
strncasecmp(err,"No support for",14) == 0); strncasecmp(reader->errstr,"No support for",14) == 0);
redisReplyReaderFree(reader); redisReaderFree(reader);
test("Works with NULL functions for reply: "); test("Works with NULL functions for reply: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
reader->fn = NULL; reader->fn = NULL;
redisReplyReaderFeed(reader,(char*)"+OK\r\n",5); redisReaderFeed(reader,(char*)"+OK\r\n",5);
ret = redisReplyReaderGetReply(reader,&reply); ret = redisReaderGetReply(reader,&reply);
test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS); 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: "); test("Works when a single newline (\\r\\n) covers two calls to feed: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
reader->fn = NULL; reader->fn = NULL;
redisReplyReaderFeed(reader,(char*)"+OK\r",4); redisReaderFeed(reader,(char*)"+OK\r",4);
ret = redisReplyReaderGetReply(reader,&reply); ret = redisReaderGetReply(reader,&reply);
assert(ret == REDIS_OK && reply == NULL); assert(ret == REDIS_OK && reply == NULL);
redisReplyReaderFeed(reader,(char*)"\n",1); redisReaderFeed(reader,(char*)"\n",1);
ret = redisReplyReaderGetReply(reader,&reply); ret = redisReaderGetReply(reader,&reply);
test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS); test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);
redisReplyReaderFree(reader); redisReaderFree(reader);
test("Don't reset state after protocol error: "); test("Don't reset state after protocol error: ");
reader = redisReplyReaderCreate(); reader = redisReaderCreate();
reader->fn = NULL; reader->fn = NULL;
redisReplyReaderFeed(reader,(char*)"x",1); redisReaderFeed(reader,(char*)"x",1);
ret = redisReplyReaderGetReply(reader,&reply); ret = redisReaderGetReply(reader,&reply);
assert(ret == REDIS_ERR); assert(ret == REDIS_ERR);
ret = redisReplyReaderGetReply(reader,&reply); ret = redisReaderGetReply(reader,&reply);
test_cond(ret == REDIS_ERR && reply == NULL); test_cond(ret == REDIS_ERR && reply == NULL);
} }