]> git.proxmox.com Git - libgit2.git/blob - tests/structinit/structinit.c
git_checkout_opts -> git_checkout_options
[libgit2.git] / tests / structinit / structinit.c
1 #include "clar_libgit2.h"
2 #include <git2/sys/config.h>
3 #include <git2/sys/odb_backend.h>
4 #include <git2/sys/refdb_backend.h>
5
6 #define STRINGIFY(s) #s
7
8 /* Checks two conditions for the specified structure:
9 * 1. That the initializers for the latest version produces the same
10 * in-memory representation.
11 * 2. That the function-based initializer supports all versions from 1...n,
12 * where n is the latest version (often represented by GIT_*_VERSION).
13 *
14 * Parameters:
15 * structname: The name of the structure to test, e.g. git_blame_options.
16 * structver: The latest version of the specified structure.
17 * macroinit: The macro that initializes the latest version of the structure.
18 * funcinitname: The function that initializes the structure. Must have the
19 * signature "int (structname* instance, int version)".
20 */
21 #define CHECK_MACRO_FUNC_INIT_EQUAL(structname, structver, macroinit, funcinitname) \
22 do { \
23 structname structname##_macro_latest = macroinit; \
24 structname structname##_func_latest; \
25 int structname##_curr_ver = structver - 1; \
26 cl_git_pass(funcinitname(&structname##_func_latest, structver)); \
27 cl_check_( \
28 memcmp(&structname##_macro_latest, &structname##_func_latest, \
29 sizeof(structname)) == 0, \
30 "Macro-based and function-based initializer for " STRINGIFY(structname) \
31 " are not equivalent."); \
32 \
33 while (structname##_curr_ver > 0) \
34 { \
35 structname macro; \
36 cl_git_pass(funcinitname(&macro, structname##_curr_ver)); \
37 structname##_curr_ver--; \
38 }\
39 } while(0)
40
41 void test_structinit_structinit__compare(void)
42 {
43 /* blame */
44 CHECK_MACRO_FUNC_INIT_EQUAL( \
45 git_blame_options, GIT_BLAME_OPTIONS_VERSION, \
46 GIT_BLAME_OPTIONS_INIT, git_blame_init_options);
47
48 /* checkout */
49 CHECK_MACRO_FUNC_INIT_EQUAL( \
50 git_checkout_options, GIT_CHECKOUT_OPTIONS_VERSION, \
51 GIT_CHECKOUT_OPTIONS_INIT, git_checkout_init_opts);
52
53 /* clone */
54 CHECK_MACRO_FUNC_INIT_EQUAL( \
55 git_clone_options, GIT_CLONE_OPTIONS_VERSION, \
56 GIT_CLONE_OPTIONS_INIT, git_clone_init_options);
57
58 /* diff */
59 CHECK_MACRO_FUNC_INIT_EQUAL( \
60 git_diff_options, GIT_DIFF_OPTIONS_VERSION, \
61 GIT_DIFF_OPTIONS_INIT, git_diff_init_options);
62
63 /* diff_find */
64 CHECK_MACRO_FUNC_INIT_EQUAL( \
65 git_diff_find_options, GIT_DIFF_FIND_OPTIONS_VERSION, \
66 GIT_DIFF_FIND_OPTIONS_INIT, git_diff_find_init_options);
67
68 /* merge_tree */
69 CHECK_MACRO_FUNC_INIT_EQUAL( \
70 git_merge_tree_opts, GIT_MERGE_TREE_OPTS_VERSION, \
71 GIT_MERGE_TREE_OPTS_INIT, git_merge_tree_init_opts);
72
73 /* merge */
74 CHECK_MACRO_FUNC_INIT_EQUAL( \
75 git_merge_opts, GIT_MERGE_OPTS_VERSION, \
76 GIT_MERGE_OPTS_INIT, git_merge_init_opts);
77
78 /* push */
79 CHECK_MACRO_FUNC_INIT_EQUAL( \
80 git_push_options, GIT_PUSH_OPTIONS_VERSION, \
81 GIT_PUSH_OPTIONS_INIT, git_push_init_options);
82
83 /* remote */
84 CHECK_MACRO_FUNC_INIT_EQUAL( \
85 git_remote_callbacks, GIT_REMOTE_CALLBACKS_VERSION, \
86 GIT_REMOTE_CALLBACKS_INIT, git_remote_init_callbacks);
87
88 /* repository_init */
89 CHECK_MACRO_FUNC_INIT_EQUAL( \
90 git_repository_init_options, GIT_REPOSITORY_INIT_OPTIONS_VERSION, \
91 GIT_REPOSITORY_INIT_OPTIONS_INIT, git_repository_init_init_options);
92
93 /* revert */
94 CHECK_MACRO_FUNC_INIT_EQUAL( \
95 git_revert_opts, GIT_REVERT_OPTS_VERSION, \
96 GIT_REVERT_OPTS_INIT, git_revert_init_opts);
97
98 /* status */
99 CHECK_MACRO_FUNC_INIT_EQUAL( \
100 git_status_options, GIT_STATUS_OPTIONS_VERSION, \
101 GIT_STATUS_OPTIONS_INIT, git_status_init_options);
102
103 /* transport */
104 CHECK_MACRO_FUNC_INIT_EQUAL( \
105 git_transport, GIT_TRANSPORT_VERSION, \
106 GIT_TRANSPORT_INIT, git_transport_init);
107
108 /* config_backend */
109 CHECK_MACRO_FUNC_INIT_EQUAL( \
110 git_config_backend, GIT_CONFIG_BACKEND_VERSION, \
111 GIT_CONFIG_BACKEND_INIT, git_config_init_backend);
112
113 /* odb_backend */
114 CHECK_MACRO_FUNC_INIT_EQUAL( \
115 git_odb_backend, GIT_ODB_BACKEND_VERSION, \
116 GIT_ODB_BACKEND_INIT, git_odb_init_backend);
117
118 /* refdb_backend */
119 CHECK_MACRO_FUNC_INIT_EQUAL( \
120 git_refdb_backend, GIT_REFDB_BACKEND_VERSION, \
121 GIT_REFDB_BACKEND_INIT, git_refdb_init_backend);
122 }