diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-07-09 14:54:01 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2011-07-09 15:08:45 +0200 |
commit | 4ac55be9b58b48a602ba23f536092eb644775f05 (patch) | |
tree | 29e7ec8ceee15a9f530c19e8d99a8f1f6360ea3c | |
parent | 5def86434e1ff4554885af3436cb2d83a8349ef3 (diff) |
Update printf-formatting tests to fail
-rw-r--r-- | test.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -142,16 +142,18 @@ static void test_format_commands(void) { len == 4+4+(3+2)+4+(1+2)+4+(1+2)); free(cmd); + /* sizeof(long long) is 8 bytes regardless of architecture */ test("Format command with printf-delegation (long long): "); - len = redisFormatCommand(&cmd,"key:%08lld",1234ll); - test_cond(strncmp(cmd,"*1\r\n$12\r\nkey:00001234\r\n",len) == 0 && - len == 4+5+(12+2)); + len = redisFormatCommand(&cmd,"key:%08lld str:%s",1234ll, "hello"); + test_cond(strncmp(cmd,"*2\r\n$12\r\nkey:00001234\r\n$9\r\nstr:hello\r\n",len) == 0 && + len == 4+5+(12+2)+4+(9+2)); free(cmd); + /* sizeof(float) is 4 bytes regardless of architecture */ test("Format command with printf-delegation (float): "); - len = redisFormatCommand(&cmd,"v:%06.1f",12.34f); - test_cond(strncmp(cmd,"*1\r\n$8\r\nv:0012.3\r\n",len) == 0 && - len == 4+4+(8+2)); + len = redisFormatCommand(&cmd,"v:%06.1f str:%s",12.34f,"hello"); + test_cond(strncmp(cmd,"*2\r\n$8\r\nv:0012.3\r\n$9\r\nstr:hello\r\n",len) == 0 && + len == 4+4+(8+2)+4+(9+2)); free(cmd); test("Format command with printf-delegation and extra interpolation: "); |