clay: Merge manually @leto's tests from #485 This uses the new Clay code. As you can see, the diff is minimal... It works!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/tests-clay/buf/basic.c b/tests-clay/buf/basic.c
new file mode 100644
index 0000000..860564d
--- /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 db3a475..2c687ee 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 4ad6fc4..16cc516 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