Commit 1d09a1c8 by Vicent Marti

clay: Merge manually @leto's tests from #485

This uses the new Clay code. As you can see, the diff is minimal... It
works!
parent 967617cc
#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
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment