mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-02 16:34:37 +00:00
clay: Merge manually @leto's tests from #485
This uses the new Clay code. As you can see, the diff is minimal... It works!
This commit is contained in:
parent
967617ccad
commit
1d09a1c88d
29
tests-clay/buf/basic.c
Normal file
29
tests-clay/buf/basic.c
Normal file
@ -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);
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user