Commit 1d09a1c88ddde32bf9b6b5ab6a9feab2ecdaa6ff

Vicent Marti 2011-11-22T01:41:22

clay: Merge manually @leto's tests from #485 This uses the new Clay code. As you can see, the diff is minimal... It works!

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