Commit 01be6f37 by Vicent Martí

Merge pull request #446 from schu/tests-clay-update

tests-clay: update
parents 3eaf34f4 1d33bf9d
Writing Clay tests for libgit2
==============================
For information on the Clay testing framework and a detailed introduction
please visit:
https://github.com/tanoku/clay
* Write your modules and tests. Use good, meaningful names.
* Mix the tests:
./clay
* Make sure you actually build the tests by setting:
BUILD_CLAY=ON
* Test:
./build/libgit2_clay
* Make sure everything is fine.
* Send your pull request. That's it.
...@@ -57,6 +57,17 @@ void cl_fixture_cleanup(const char *fixture_name); ...@@ -57,6 +57,17 @@ void cl_fixture_cleanup(const char *fixture_name);
/** /**
* Test method declarations * Test method declarations
*/ */
extern void test_status_single__hash_single_file(void);
extern void test_status_worktree__initialize(void);
extern void test_status_worktree__cleanup(void);
extern void test_status_worktree__whole_repository(void);
extern void test_status_worktree__empty_repository(void);
extern void test_network_remotes__initialize(void);
extern void test_network_remotes__cleanup(void);
extern void test_network_remotes__parsing(void);
extern void test_network_remotes__refspec_parsing(void);
extern void test_network_remotes__fnmatch(void);
extern void test_network_remotes__transform(void);
extern void test_core_dirent__dont_traverse_dot(void); extern void test_core_dirent__dont_traverse_dot(void);
extern void test_core_dirent__traverse_subfolder(void); extern void test_core_dirent__traverse_subfolder(void);
extern void test_core_dirent__traverse_slash_terminated_folder(void); extern void test_core_dirent__traverse_slash_terminated_folder(void);
...@@ -75,19 +86,10 @@ extern void test_core_rmdir__delete_recursive(void); ...@@ -75,19 +86,10 @@ extern void test_core_rmdir__delete_recursive(void);
extern void test_core_rmdir__fail_to_delete_non_empty_dir(void); extern void test_core_rmdir__fail_to_delete_non_empty_dir(void);
extern void test_core_string__0(void); extern void test_core_string__0(void);
extern void test_core_string__1(void); extern void test_core_string__1(void);
extern void test_core_strtol__int32(void);
extern void test_core_strtol__int64(void);
extern void test_core_vector__0(void); extern void test_core_vector__0(void);
extern void test_core_vector__1(void); extern void test_core_vector__1(void);
extern void test_core_vector__2(void); extern void test_core_vector__2(void);
extern void test_network_remotes__initialize(void);
extern void test_network_remotes__cleanup(void);
extern void test_network_remotes__parsing(void);
extern void test_network_remotes__refspec_parsing(void);
extern void test_network_remotes__fnmatch(void);
extern void test_network_remotes__transform(void);
extern void test_status_single__hash_single_file(void);
extern void test_status_worktree__initialize(void);
extern void test_status_worktree__cleanup(void);
extern void test_status_worktree__whole_repository(void);
extern void test_status_worktree__empty_repository(void);
#endif #endif
...@@ -660,99 +660,107 @@ cl_fs_cleanup(void) ...@@ -660,99 +660,107 @@ cl_fs_cleanup(void)
static const struct clay_func _all_callbacks[] = { static const struct clay_func _all_callbacks[] = {
{"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 0}, {"hash_single_file", &test_status_single__hash_single_file, 0},
{"traverse_subfolder", &test_core_dirent__traverse_subfolder, 0}, {"whole_repository", &test_status_worktree__whole_repository, 1},
{"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder, 0}, {"empty_repository", &test_status_worktree__empty_repository, 1},
{"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders, 0}, {"parsing", &test_network_remotes__parsing, 2},
{"traverse_weird_filenames", &test_core_dirent__traverse_weird_filenames, 0}, {"refspec_parsing", &test_network_remotes__refspec_parsing, 2},
{"0", &test_core_filebuf__0, 1}, {"fnmatch", &test_network_remotes__fnmatch, 2},
{"1", &test_core_filebuf__1, 1}, {"transform", &test_network_remotes__transform, 2},
{"2", &test_core_filebuf__2, 1}, {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 3},
{"0", &test_core_path__0, 2}, {"traverse_subfolder", &test_core_dirent__traverse_subfolder, 3},
{"1", &test_core_path__1, 2}, {"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder, 3},
{"2", &test_core_path__2, 2}, {"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders, 3},
{"5", &test_core_path__5, 2}, {"traverse_weird_filenames", &test_core_dirent__traverse_weird_filenames, 3},
{"6", &test_core_path__6, 2}, {"0", &test_core_filebuf__0, 4},
{"delete_recursive", &test_core_rmdir__delete_recursive, 3}, {"1", &test_core_filebuf__1, 4},
{"fail_to_delete_non_empty_dir", &test_core_rmdir__fail_to_delete_non_empty_dir, 3}, {"2", &test_core_filebuf__2, 4},
{"0", &test_core_string__0, 4}, {"0", &test_core_path__0, 5},
{"1", &test_core_string__1, 4}, {"1", &test_core_path__1, 5},
{"0", &test_core_vector__0, 5}, {"2", &test_core_path__2, 5},
{"1", &test_core_vector__1, 5}, {"5", &test_core_path__5, 5},
{"2", &test_core_vector__2, 5}, {"6", &test_core_path__6, 5},
{"parsing", &test_network_remotes__parsing, 6}, {"delete_recursive", &test_core_rmdir__delete_recursive, 6},
{"refspec_parsing", &test_network_remotes__refspec_parsing, 6}, {"fail_to_delete_non_empty_dir", &test_core_rmdir__fail_to_delete_non_empty_dir, 6},
{"fnmatch", &test_network_remotes__fnmatch, 6}, {"0", &test_core_string__0, 7},
{"transform", &test_network_remotes__transform, 6}, {"1", &test_core_string__1, 7},
{"hash_single_file", &test_status_single__hash_single_file, 7}, {"int32", &test_core_strtol__int32, 8},
{"whole_repository", &test_status_worktree__whole_repository, 8}, {"int64", &test_core_strtol__int64, 8},
{"empty_repository", &test_status_worktree__empty_repository, 8} {"0", &test_core_vector__0, 9},
{"1", &test_core_vector__1, 9},
{"2", &test_core_vector__2, 9}
}; };
static const struct clay_suite _all_suites[] = { static const struct clay_suite _all_suites[] = {
{ {
"status::single",
{NULL, NULL, 0},
{NULL, NULL, 0},
&_all_callbacks[0], 1
},
{
"status::worktree",
{"initialize", &test_status_worktree__initialize, 1},
{"cleanup", &test_status_worktree__cleanup, 1},
&_all_callbacks[1], 2
},
{
"network::remotes",
{"initialize", &test_network_remotes__initialize, 2},
{"cleanup", &test_network_remotes__cleanup, 2},
&_all_callbacks[3], 4
},
{
"core::dirent", "core::dirent",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[0], 5 &_all_callbacks[7], 5
}, },
{ {
"core::filebuf", "core::filebuf",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[5], 3 &_all_callbacks[12], 3
}, },
{ {
"core::path", "core::path",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[8], 5 &_all_callbacks[15], 5
}, },
{ {
"core::rmdir", "core::rmdir",
{"initialize", &test_core_rmdir__initialize, 3}, {"initialize", &test_core_rmdir__initialize, 6},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[13], 2 &_all_callbacks[20], 2
}, },
{ {
"core::string", "core::string",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[15], 2 &_all_callbacks[22], 2
}, },
{ {
"core::vector", "core::strtol",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[17], 3 &_all_callbacks[24], 2
},
{
"network::remotes",
{"initialize", &test_network_remotes__initialize, 6},
{"cleanup", &test_network_remotes__cleanup, 6},
&_all_callbacks[20], 4
}, },
{ {
"status::single", "core::vector",
{NULL, NULL, 0}, {NULL, NULL, 0},
{NULL, NULL, 0}, {NULL, NULL, 0},
&_all_callbacks[24], 1 &_all_callbacks[26], 3
},
{
"status::worktree",
{"initialize", &test_status_worktree__initialize, 8},
{"cleanup", &test_status_worktree__cleanup, 8},
&_all_callbacks[25], 2
} }
}; };
static const char _suites_str[] = "core::dirent, core::filebuf, core::path, core::rmdir, core::string, core::vector, network::remotes, status::single, status::worktree"; static const char _suites_str[] = "status::single, status::worktree, network::remotes, core::dirent, core::filebuf, core::path, core::rmdir, core::string, core::strtol, core::vector";
int _MAIN_CC main(int argc, char *argv[]) int _MAIN_CC main(int argc, char *argv[])
{ {
return clay_test( return clay_test(
argc, argv, _suites_str, argc, argv, _suites_str,
_all_callbacks, 27, _all_callbacks, 29,
_all_suites, 9 _all_suites, 10
); );
} }
#include "clay_libgit2.h"
void test_core_strtol__int32(void)
{
int32_t i;
cl_git_pass(git__strtol32(&i, "123", NULL, 10));
cl_assert(i == 123);
cl_git_pass(git__strtol32(&i, " +123 ", NULL, 10));
cl_assert(i == 123);
cl_git_pass(git__strtol32(&i, " +2147483647 ", NULL, 10));
cl_assert(i == 2147483647);
cl_git_pass(git__strtol32(&i, " -2147483648 ", NULL, 10));
cl_assert(i == -2147483648LL);
cl_git_fail(git__strtol32(&i, " 2147483657 ", NULL, 10));
cl_git_fail(git__strtol32(&i, " -2147483657 ", NULL, 10));
}
void test_core_strtol__int64(void)
{
int64_t i;
cl_git_pass(git__strtol64(&i, "123", NULL, 10));
cl_assert(i == 123);
cl_git_pass(git__strtol64(&i, " +123 ", NULL, 10));
cl_assert(i == 123);
cl_git_pass(git__strtol64(&i, " +2147483647 ", NULL, 10));
cl_assert(i == 2147483647);
cl_git_pass(git__strtol64(&i, " -2147483648 ", NULL, 10));
cl_assert(i == -2147483648LL);
cl_git_pass(git__strtol64(&i, " 2147483657 ", NULL, 10));
cl_assert(i == 2147483657LL);
cl_git_pass(git__strtol64(&i, " -2147483657 ", NULL, 10));
cl_assert(i == -2147483657LL);
}
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