+ repo_set_hash_algo(the_repository, algo);
}
-int cmd_main(int argc UNUSED, const char **argv UNUSED)
+static const char *arr_input[] = { "88", "44", "aa", "55" };
+static const char *arr_input_dup[] = { "88", "44", "aa", "55",
+ "88", "44", "aa", "55",
+ "88", "44", "aa", "55" };
+static const char *res_sorted[] = { "44", "55", "88", "aa" };
+
+void test_oid_array__enumerate_unique(void)
{
- const char *arr_input[] = { "88", "44", "aa", "55" };
- const char *arr_input_dup[] = { "88", "44", "aa", "55",
- "88", "44", "aa", "55",
- "88", "44", "aa", "55" };
- const char *res_sorted[] = { "44", "55", "88", "aa" };
- const char *nearly_55;
+ TEST_ENUMERATION(arr_input, res_sorted);
+}
+
+void test_oid_array__enumerate_duplicate(void)
+{
+ TEST_ENUMERATION(arr_input_dup, res_sorted);
+}
+
+void test_oid_array__lookup(void)
+{
+ TEST_LOOKUP(arr_input, "55", 1, 1);
+}
- if (!TEST(setup(), "setup"))
- test_skip_all("hash algo initialization failed");
+void test_oid_array__lookup_non_existent(void)
+{
+ TEST_LOOKUP(arr_input, "33", INT_MIN, -1);
+}
+
+void test_oid_array__lookup_duplicates(void)
+{
+ TEST_LOOKUP(arr_input_dup, "55", 3, 5);
+}
- TEST_ENUMERATION(arr_input, res_sorted, "ordered enumeration");
- TEST_ENUMERATION(arr_input_dup, res_sorted,
- "ordered enumeration with duplicate suppression");
+void test_oid_array__lookup_non_existent_dup(void)
+{
+ TEST_LOOKUP(arr_input_dup, "66", INT_MIN, -1);
+}
- TEST_LOOKUP(arr_input, "55", 1, 1, "lookup");
- TEST_LOOKUP(arr_input, "33", INT_MIN, -1, "lookup non-existent entry");
- TEST_LOOKUP(arr_input_dup, "55", 3, 5, "lookup with duplicates");
- TEST_LOOKUP(arr_input_dup, "66", INT_MIN, -1,
- "lookup non-existent entry with duplicates");
+void test_oid_array__lookup_almost_dup(void)
+{
+ const char *nearly_55;
nearly_55 = init_hash_algo() == GIT_HASH_SHA1 ?
"5500000000000000000000000000000000000001" :
"5500000000000000000000000000000000000000000000000000000000000001";
- TEST_LOOKUP(((const char *[]){ "55", nearly_55 }), "55", 0, 0,
- "lookup with almost duplicate values");
- TEST_LOOKUP(((const char *[]){ "55", "55" }), "55", 0, 1,
- "lookup with single duplicate value");
- return test_done();
+ TEST_LOOKUP(((const char *[]){ "55", nearly_55 }), "55", 0, 0);
+}
+
+void test_oid_array__lookup_single_dup(void)
+{
+ TEST_LOOKUP(((const char *[]){ "55", "55" }), "55", 0, 1);
}