Commit c7dd0a56 by Jacques Germishuys

Use p_snprintf also in tests

parent c983604e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "clar.h" #include "clar.h"
#include <git2.h> #include <git2.h>
#include <posix.h>
#include "common.h" #include "common.h"
/** /**
...@@ -51,7 +52,7 @@ GIT_INLINE(void) clar__assert_in_range( ...@@ -51,7 +52,7 @@ GIT_INLINE(void) clar__assert_in_range(
{ {
if (lo > val || hi < val) { if (lo > val || hi < val) {
char buf[128]; char buf[128];
snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi); p_snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi);
clar__fail(file, line, err, buf, should_abort); clar__fail(file, line, err, buf, should_abort);
} }
} }
......
...@@ -91,12 +91,12 @@ void test_refs_pack__symbolic(void) ...@@ -91,12 +91,12 @@ void test_refs_pack__symbolic(void)
/* make a bunch of references */ /* make a bunch of references */
for (i = 0; i < 100; ++i) { for (i = 0; i < 100; ++i) {
snprintf(name, sizeof(name), "refs/heads/symbolic-%03d", i); p_snprintf(name, sizeof(name), "refs/heads/symbolic-%03d", i);
cl_git_pass(git_reference_symbolic_create( cl_git_pass(git_reference_symbolic_create(
&ref, g_repo, name, "refs/heads/master", 0, NULL, NULL)); &ref, g_repo, name, "refs/heads/master", 0, NULL, NULL));
git_reference_free(ref); git_reference_free(ref);
snprintf(name, sizeof(name), "refs/heads/direct-%03d", i); p_snprintf(name, sizeof(name), "refs/heads/direct-%03d", i);
cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL)); cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL));
git_reference_free(ref); git_reference_free(ref);
} }
......
...@@ -97,14 +97,14 @@ void test_stress_diff__rename_big_files(void) ...@@ -97,14 +97,14 @@ void test_stress_diff__rename_big_files(void)
cl_git_pass(git_repository_index(&index, g_repo)); cl_git_pass(git_repository_index(&index, g_repo));
for (i = 0; i < 100; i += 1) { for (i = 0; i < 100; i += 1) {
snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i); p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
for (j = i * 256; j > 0; --j) for (j = i * 256; j > 0; --j)
git_buf_printf(&b, "more content %d\n", i); git_buf_printf(&b, "more content %d\n", i);
cl_git_mkfile(tmp, b.ptr); cl_git_mkfile(tmp, b.ptr);
} }
for (i = 0; i < 100; i += 1) { for (i = 0; i < 100; i += 1) {
snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i); p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/"))); cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
} }
...@@ -128,15 +128,15 @@ void test_stress_diff__rename_many_files(void) ...@@ -128,15 +128,15 @@ void test_stress_diff__rename_many_files(void)
git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0); git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
for (i = 0; i < 2500; i += 1) { for (i = 0; i < 2500; i += 1) {
snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i); p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
snprintf(b.ptr, 9, "%08d", i); p_snprintf(b.ptr, 9, "%08d", i);
b.ptr[8] = '\n'; b.ptr[8] = '\n';
cl_git_mkfile(tmp, b.ptr); cl_git_mkfile(tmp, b.ptr);
} }
git_buf_free(&b); git_buf_free(&b);
for (i = 0; i < 2500; i += 1) { for (i = 0; i < 2500; i += 1) {
snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i); p_snprintf(tmp, sizeof(tmp), "renames/newfile%03d", i);
cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/"))); cl_git_pass(git_index_add_bypath(index, tmp + strlen("renames/")));
} }
......
...@@ -58,7 +58,7 @@ void test_threads_refdb__iterator(void) ...@@ -58,7 +58,7 @@ void test_threads_refdb__iterator(void)
/* make a bunch of references */ /* make a bunch of references */
for (r = 0; r < 200; ++r) { for (r = 0; r < 200; ++r) {
snprintf(name, sizeof(name), "refs/heads/direct-%03d", r); p_snprintf(name, sizeof(name), "refs/heads/direct-%03d", r);
cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL)); cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL));
git_reference_free(ref); git_reference_free(ref);
} }
...@@ -102,7 +102,7 @@ static void *create_refs(void *arg) ...@@ -102,7 +102,7 @@ static void *create_refs(void *arg)
cl_git_pass(git_reference_name_to_id(&head, g_repo, "HEAD")); cl_git_pass(git_reference_name_to_id(&head, g_repo, "HEAD"));
for (i = 0; i < 10; ++i) { for (i = 0; i < 10; ++i) {
snprintf(name, sizeof(name), "refs/heads/thread-%03d-%02d", *id, i); p_snprintf(name, sizeof(name), "refs/heads/thread-%03d-%02d", *id, i);
cl_git_pass(git_reference_create(&ref[i], g_repo, name, &head, 0, NULL, NULL)); cl_git_pass(git_reference_create(&ref[i], g_repo, name, &head, 0, NULL, NULL));
if (i == 5) { if (i == 5) {
...@@ -127,7 +127,7 @@ static void *delete_refs(void *arg) ...@@ -127,7 +127,7 @@ static void *delete_refs(void *arg)
char name[128]; char name[128];
for (i = 0; i < 10; ++i) { for (i = 0; i < 10; ++i) {
snprintf( p_snprintf(
name, sizeof(name), "refs/heads/thread-%03d-%02d", (*id) & ~0x3, i); name, sizeof(name), "refs/heads/thread-%03d-%02d", (*id) & ~0x3, i);
if (!git_reference_lookup(&ref, g_repo, name)) { if (!git_reference_lookup(&ref, g_repo, name)) {
...@@ -167,7 +167,7 @@ void test_threads_refdb__edit_while_iterate(void) ...@@ -167,7 +167,7 @@ void test_threads_refdb__edit_while_iterate(void)
/* make a bunch of references */ /* make a bunch of references */
for (r = 0; r < 50; ++r) { for (r = 0; r < 50; ++r) {
snprintf(name, sizeof(name), "refs/heads/starter-%03d", r); p_snprintf(name, sizeof(name), "refs/heads/starter-%03d", r);
cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL)); cl_git_pass(git_reference_create(&ref, g_repo, name, &head, 0, NULL, NULL));
git_reference_free(ref); git_reference_free(ref);
} }
......
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