From 1d09a1c88ddde32bf9b6b5ab6a9feab2ecdaa6ff Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Tue, 22 Nov 2011 01:41:22 +0100 Subject: [PATCH] clay: Merge manually @leto's tests from #485 This uses the new Clay code. As you can see, the diff is minimal... It works! --- tests-clay/buf/basic.c | 29 +++++++++++++++++++++++++++++ tests-clay/clay.h | 2 ++ tests-clay/clay_main.c | 14 ++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests-clay/buf/basic.c diff --git a/tests-clay/buf/basic.c b/tests-clay/buf/basic.c new file mode 100644 index 000000000..860564d13 --- /dev/null +++ b/tests-clay/buf/basic.c @@ -0,0 +1,29 @@ +#include "clay_libgit2.h" +#include "buffer.h" + +static const char *test_string = "Have you seen that? Have you seeeen that??"; + +void test_buf_basic__resize(void) +{ + git_buf buf1 = GIT_BUF_INIT; + git_buf_puts(&buf1, test_string); + cl_assert(git_buf_oom(&buf1) == 0); + cl_assert(strcmp(git_buf_cstr(&buf1), test_string) == 0); + + git_buf_puts(&buf1, test_string); + cl_assert(strlen(git_buf_cstr(&buf1)) == strlen(test_string) * 2); + git_buf_free(&buf1); +} + +void test_buf_basic__printf(void) +{ + git_buf buf2 = GIT_BUF_INIT; + git_buf_printf(&buf2, "%s %s %d ", "shoop", "da", 23); + cl_assert(git_buf_oom(&buf2) == 0); + cl_assert(strcmp(git_buf_cstr(&buf2), "shoop da 23 ") == 0); + + git_buf_printf(&buf2, "%s %d", "woop", 42); + cl_assert(git_buf_oom(&buf2) == 0); + cl_assert(strcmp(git_buf_cstr(&buf2), "shoop da 23 woop 42") == 0); + git_buf_free(&buf2); +} \ No newline at end of file diff --git a/tests-clay/clay.h b/tests-clay/clay.h index db3a475b2..2c687ee5a 100644 --- a/tests-clay/clay.h +++ b/tests-clay/clay.h @@ -57,6 +57,8 @@ void cl_fixture_cleanup(const char *fixture_name); /** * Test method declarations */ +extern void test_buf_basic__printf(void); +extern void test_buf_basic__resize(void); extern void test_config_stress__cleanup(void); extern void test_config_stress__dont_break_on_invalid_input(void); extern void test_config_stress__initialize(void); diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c index 4ad6fc467..16cc516fa 100644 --- a/tests-clay/clay_main.c +++ b/tests-clay/clay_main.c @@ -104,6 +104,10 @@ static void clay_unsandbox(void); static int clay_sandbox(void); /* Autogenerated test data by clay */ +static const struct clay_func _clay_cb_buf_basic[] = { + {"printf", &test_buf_basic__printf}, + {"resize", &test_buf_basic__resize} +}; static const struct clay_func _clay_cb_config_stress[] = { {"dont_break_on_invalid_input", &test_config_stress__dont_break_on_invalid_input} }; @@ -216,6 +220,12 @@ static const struct clay_func _clay_cb_status_worktree[] = { static const struct clay_suite _clay_suites[] = { { + "buf::basic", + {NULL, NULL}, + {NULL, NULL}, + _clay_cb_buf_basic, 2 + }, + { "config::stress", {"initialize", &test_config_stress__initialize}, {"cleanup", &test_config_stress__cleanup}, @@ -349,8 +359,8 @@ static const struct clay_suite _clay_suites[] = { } }; -static size_t _clay_suite_count = 22; -static size_t _clay_callback_count = 65; +static size_t _clay_suite_count = 23; +static size_t _clay_callback_count = 67; /* Core test functions */ static void