mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-10-05 21:27:56 +03:00
Appl new code style on whole code base
Use a similar code style to bemanitools though reduce indentation to 2 spaces. Also some other tweaks to be more similar to google style.
This commit is contained in:
@@ -8,66 +8,65 @@ typedef int (*test_mock_function_t)(int a);
|
||||
|
||||
static int test_mock_function(int a)
|
||||
{
|
||||
return a * 2;
|
||||
return a * 2;
|
||||
}
|
||||
|
||||
static void test_cnh_lib_mock_init_unit_test(void** state)
|
||||
static void test_cnh_lib_mock_init_unit_test(void **state)
|
||||
{
|
||||
struct cnh_lib_unit_test_func_mocks* mocks;
|
||||
size_t mocks_cnt;
|
||||
void* ptr;
|
||||
struct cnh_lib_unit_test_func_mocks *mocks;
|
||||
size_t mocks_cnt;
|
||||
void *ptr;
|
||||
|
||||
mocks_cnt = 1;
|
||||
mocks = cnh_lib_allocate_func_mocks(mocks_cnt);
|
||||
mocks_cnt = 1;
|
||||
mocks = cnh_lib_allocate_func_mocks(mocks_cnt);
|
||||
|
||||
mocks[0].name = "test_mock_function";
|
||||
mocks[0].func = test_mock_function;
|
||||
mocks[0].name = "test_mock_function";
|
||||
mocks[0].func = test_mock_function;
|
||||
|
||||
cnh_lib_init_unit_test(mocks, mocks_cnt);
|
||||
cnh_lib_init_unit_test(mocks, mocks_cnt);
|
||||
|
||||
ptr = cnh_lib_load("asdf");
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
ptr = cnh_lib_load("asdf");
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
|
||||
ptr = cnh_lib_get_func_addr_handle(ptr, "test_mock_function");
|
||||
assert_ptr_equal(ptr, test_mock_function);
|
||||
ptr = cnh_lib_get_func_addr_handle(ptr, "test_mock_function");
|
||||
assert_ptr_equal(ptr, test_mock_function);
|
||||
|
||||
assert_int_equal(((test_mock_function_t) ptr)(2), 4);
|
||||
assert_int_equal(((test_mock_function_t) ptr)(2), 4);
|
||||
|
||||
ptr = cnh_lib_get_func_addr_handle(ptr, "asdf");
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
ptr = cnh_lib_get_func_addr_handle(ptr, "asdf");
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
|
||||
cnh_lib_unload(ptr);
|
||||
// Nothing happens here
|
||||
cnh_lib_unload(ptr);
|
||||
// Nothing happens here
|
||||
|
||||
ptr = cnh_lib_get_func_addr( "test_mock_function");
|
||||
assert_ptr_equal(ptr, test_mock_function);
|
||||
ptr = cnh_lib_get_func_addr("test_mock_function");
|
||||
assert_ptr_equal(ptr, test_mock_function);
|
||||
|
||||
cnh_lib_shutdown_unit_test();
|
||||
cnh_lib_shutdown_unit_test();
|
||||
}
|
||||
|
||||
static void test_cnh_lib_real(void** state)
|
||||
static void test_cnh_lib_real(void **state)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
cnh_lib_init();
|
||||
cnh_lib_init();
|
||||
|
||||
ptr = cnh_lib_load("libc.so.6");
|
||||
ptr = cnh_lib_load("libc.so.6");
|
||||
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
assert_ptr_equal(cnh_lib_load("asdfasdas"), NULL);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
assert_ptr_equal(cnh_lib_load("asdfasdas"), NULL);
|
||||
|
||||
assert_ptr_not_equal(cnh_lib_get_func_addr_handle(ptr, "printf"), NULL);
|
||||
assert_ptr_not_equal(cnh_lib_get_func_addr("printf"), NULL);
|
||||
assert_ptr_not_equal(cnh_lib_get_func_addr_handle(ptr, "printf"), NULL);
|
||||
assert_ptr_not_equal(cnh_lib_get_func_addr("printf"), NULL);
|
||||
|
||||
assert_ptr_equal(cnh_lib_get_func_addr("asdasdas"), NULL);
|
||||
assert_ptr_equal(cnh_lib_get_func_addr("asdasdas"), NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const struct CMUnitTest tests[] ={
|
||||
cmocka_unit_test(test_cnh_lib_mock_init_unit_test),
|
||||
cmocka_unit_test(test_cnh_lib_real)
|
||||
};
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(test_cnh_lib_mock_init_unit_test),
|
||||
cmocka_unit_test(test_cnh_lib_real)};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user