mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2026-09-27 01:00:28 +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);
|
||||
}
|
||||
@@ -11,135 +11,133 @@
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
static const char* readlink_return_value = "../devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host7/target7:0:0/7:0:0:0/block/sde";
|
||||
static const char* player1_match_buf = "../devices/pci0000:00/0000:00:14.0/usb2/1-1/1-1:1.0";
|
||||
static const char* player2_match_buf = "../devices/pci0000:00/0000:00:14.0/usb2/1-2/1-2:1.0";
|
||||
static const char *readlink_return_value =
|
||||
"../devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/host7/target7:0:0/"
|
||||
"7:0:0:0/block/sde";
|
||||
static const char *player1_match_buf =
|
||||
"../devices/pci0000:00/0000:00:14.0/usb2/1-1/1-1:1.0";
|
||||
static const char *player2_match_buf =
|
||||
"../devices/pci0000:00/0000:00:14.0/usb2/1-2/1-2:1.0";
|
||||
|
||||
extern ssize_t propatch_usb_fix_readlink(const char* path, char* buf, size_t len);
|
||||
extern ssize_t
|
||||
propatch_usb_fix_readlink(const char *path, char *buf, size_t len);
|
||||
|
||||
static uint32_t readlink_call_count = 0;
|
||||
|
||||
ssize_t readlink_mock(const char* path, char* buf, size_t len)
|
||||
ssize_t readlink_mock(const char *path, char *buf, size_t len)
|
||||
{
|
||||
ssize_t len_return;
|
||||
ssize_t len_return;
|
||||
|
||||
readlink_call_count++;
|
||||
readlink_call_count++;
|
||||
|
||||
len_return = strlen(readlink_return_value);
|
||||
len_return = strlen(readlink_return_value);
|
||||
|
||||
assert_true(len >= len_return);
|
||||
assert_true(len >= len_return);
|
||||
|
||||
strcpy(buf, readlink_return_value);
|
||||
strcpy(buf, readlink_return_value);
|
||||
|
||||
return len_return;
|
||||
return len_return;
|
||||
}
|
||||
|
||||
static int setup(void** state)
|
||||
static int setup(void **state)
|
||||
{
|
||||
struct cnh_lib_unit_test_func_mocks* func_mocks;
|
||||
size_t func_mocks_cnt;
|
||||
struct cnh_lib_unit_test_func_mocks *func_mocks;
|
||||
size_t func_mocks_cnt;
|
||||
|
||||
test_util_mem_install_mem_interface();
|
||||
test_util_mem_install_mem_interface();
|
||||
|
||||
func_mocks_cnt = 1;
|
||||
func_mocks = cnh_lib_allocate_func_mocks(func_mocks_cnt);
|
||||
func_mocks_cnt = 1;
|
||||
func_mocks = cnh_lib_allocate_func_mocks(func_mocks_cnt);
|
||||
|
||||
func_mocks[0].name = "readlink";
|
||||
func_mocks[0].func = readlink_mock;
|
||||
func_mocks[0].name = "readlink";
|
||||
func_mocks[0].func = readlink_mock;
|
||||
|
||||
cnh_lib_init_unit_test(func_mocks, func_mocks_cnt);
|
||||
cnh_lib_init_unit_test(func_mocks, func_mocks_cnt);
|
||||
|
||||
readlink_call_count = 0;
|
||||
readlink_call_count = 0;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int teardown(void** state)
|
||||
static int teardown(void **state)
|
||||
{
|
||||
propatch_usb_fix_shutdown();
|
||||
propatch_usb_fix_shutdown();
|
||||
|
||||
cnh_lib_shutdown_unit_test();
|
||||
cnh_lib_shutdown_unit_test();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_usb_fix_disabled(void** state)
|
||||
static void test_usb_fix_disabled(void **state)
|
||||
{
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device",
|
||||
buffer,
|
||||
sizeof(buffer));
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device", buffer, sizeof(buffer));
|
||||
|
||||
assert_int_equal(res, strlen(readlink_return_value));
|
||||
assert_string_equal(buffer, readlink_return_value);
|
||||
assert_int_equal(res, strlen(readlink_return_value));
|
||||
assert_string_equal(buffer, readlink_return_value);
|
||||
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
}
|
||||
|
||||
static void test_no_match_usb_fix(void** state)
|
||||
static void test_no_match_usb_fix(void **state)
|
||||
{
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
|
||||
propatch_usb_fix_init("sdd,sdf", "2-1", "2-2");
|
||||
propatch_usb_fix_init("sdd,sdf", "2-1", "2-2");
|
||||
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device",
|
||||
buffer,
|
||||
sizeof(buffer));
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device", buffer, sizeof(buffer));
|
||||
|
||||
assert_int_equal(res, strlen(readlink_return_value));
|
||||
assert_int_equal(res, strlen(readlink_return_value));
|
||||
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
}
|
||||
|
||||
static void test_match_player1_usb_fix(void** state)
|
||||
static void test_match_player1_usb_fix(void **state)
|
||||
{
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
|
||||
propatch_usb_fix_init("sde,sdf", "2-1", "2-2");
|
||||
propatch_usb_fix_init("sde,sdf", "2-1", "2-2");
|
||||
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device",
|
||||
buffer,
|
||||
sizeof(buffer));
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device", buffer, sizeof(buffer));
|
||||
|
||||
assert_int_equal(res, strlen(player1_match_buf));
|
||||
assert_string_equal(buffer, player1_match_buf);
|
||||
assert_int_equal(res, strlen(player1_match_buf));
|
||||
assert_string_equal(buffer, player1_match_buf);
|
||||
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
}
|
||||
|
||||
static void test_match_player2_usb_fix(void** state)
|
||||
static void test_match_player2_usb_fix(void **state)
|
||||
{
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
ssize_t res;
|
||||
char buffer[256];
|
||||
|
||||
propatch_usb_fix_init("sde,sdf", "2-2", "2-1");
|
||||
propatch_usb_fix_init("sde,sdf", "2-2", "2-1");
|
||||
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device",
|
||||
buffer,
|
||||
sizeof(buffer));
|
||||
res = propatch_usb_fix_readlink(
|
||||
"/sys/block/sde/device", buffer, sizeof(buffer));
|
||||
|
||||
assert_int_equal(res, strlen(player2_match_buf));
|
||||
assert_string_equal(buffer, player2_match_buf);
|
||||
assert_int_equal(res, strlen(player2_match_buf));
|
||||
assert_string_equal(buffer, player2_match_buf);
|
||||
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
assert_int_equal(readlink_call_count, 1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const struct CMUnitTest tests[] ={
|
||||
cmocka_unit_test_setup_teardown(test_usb_fix_disabled, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(test_no_match_usb_fix, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(test_match_player1_usb_fix, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(test_match_player2_usb_fix, setup, teardown)
|
||||
};
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(test_usb_fix_disabled, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(test_no_match_usb_fix, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
test_match_player1_usb_fix, setup, teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
test_match_player2_usb_fix, setup, teardown)};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
+19
-19
@@ -7,37 +7,37 @@
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
|
||||
static void* _test_util_mem_xmalloc(size_t nbytes)
|
||||
static void *_test_util_mem_xmalloc(size_t nbytes)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
ptr = test_malloc(nbytes);
|
||||
ptr = test_malloc(nbytes);
|
||||
|
||||
log_debug("malloc(%d): %p", nbytes, ptr);
|
||||
log_debug("malloc(%d): %p", nbytes, ptr);
|
||||
|
||||
return ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void* _test_util_mem_xrealloc(void* mem, size_t nbytes)
|
||||
static void *_test_util_mem_xrealloc(void *mem, size_t nbytes)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
ptr = test_realloc(mem, nbytes);
|
||||
ptr = test_realloc(mem, nbytes);
|
||||
|
||||
log_debug("realloc(%p %d): %p", mem, nbytes, ptr);
|
||||
log_debug("realloc(%p %d): %p", mem, nbytes, ptr);
|
||||
|
||||
return ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void _test_util_mem_xfree(void** mem)
|
||||
static void _test_util_mem_xfree(void **mem)
|
||||
{
|
||||
if (*mem != NULL) {
|
||||
log_debug("free(%p %p)", mem, *mem);
|
||||
test_free(*mem);
|
||||
*mem = NULL;
|
||||
} else {
|
||||
log_warn("free(%p NULL)", mem);
|
||||
}
|
||||
if (*mem != NULL) {
|
||||
log_debug("free(%p %p)", mem, *mem);
|
||||
test_free(*mem);
|
||||
*mem = NULL;
|
||||
} else {
|
||||
log_warn("free(%p NULL)", mem);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct util_mem_interface _test_util_mem_interface_test = {
|
||||
@@ -48,5 +48,5 @@ static const struct util_mem_interface _test_util_mem_interface_test = {
|
||||
|
||||
void test_util_mem_install_mem_interface()
|
||||
{
|
||||
util_mem_init(&_test_util_mem_interface_test);
|
||||
util_mem_init(&_test_util_mem_interface_test);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Install the memory test interface which is backed by cmocka for leak and error detection on unit tests.
|
||||
* Install the memory test interface which is backed by cmocka for leak and
|
||||
* error detection on unit tests.
|
||||
*/
|
||||
void test_util_mem_install_mem_interface();
|
||||
+25
-26
@@ -4,47 +4,46 @@
|
||||
|
||||
#include "util/mem.h"
|
||||
|
||||
static void test_util_mem_mock_interface(void** state)
|
||||
static void test_util_mem_mock_interface(void **state)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
test_util_mem_install_mem_interface();
|
||||
test_util_mem_install_mem_interface();
|
||||
|
||||
ptr = util_xmalloc(100);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
ptr = util_xmalloc(100);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
|
||||
ptr = util_xrealloc(ptr, 200);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
ptr = util_xrealloc(ptr, 200);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
|
||||
util_xfree(&ptr);
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
util_xfree(&ptr);
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
}
|
||||
|
||||
static void test_util_mem_real(void** state)
|
||||
static void test_util_mem_real(void **state)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
util_mem_init_default();
|
||||
util_mem_init_default();
|
||||
|
||||
ptr = util_xmalloc(100);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
ptr = util_xmalloc(100);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
|
||||
ptr = util_xrealloc(ptr, 200);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
ptr = util_xrealloc(ptr, 200);
|
||||
assert_ptr_not_equal(ptr, NULL);
|
||||
|
||||
util_xfree(&ptr);
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
util_xfree(&ptr);
|
||||
assert_ptr_equal(ptr, NULL);
|
||||
|
||||
// Should not crash
|
||||
util_xfree(&ptr);
|
||||
// Should not crash
|
||||
util_xfree(&ptr);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const struct CMUnitTest tests[] ={
|
||||
cmocka_unit_test(test_util_mem_mock_interface),
|
||||
cmocka_unit_test(test_util_mem_real)
|
||||
};
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(test_util_mem_mock_interface),
|
||||
cmocka_unit_test(test_util_mem_real)};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
+52
-53
@@ -5,97 +5,96 @@
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
|
||||
static int setup(void** state)
|
||||
static int setup(void **state)
|
||||
{
|
||||
test_util_mem_install_mem_interface();
|
||||
test_util_mem_install_mem_interface();
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_str_dup(void** state)
|
||||
static void test_str_dup(void **state)
|
||||
{
|
||||
char* str;
|
||||
char *str;
|
||||
|
||||
str = util_str_dup("aasdf");
|
||||
assert_string_equal(str, "aasdf");
|
||||
str = util_str_dup("aasdf");
|
||||
assert_string_equal(str, "aasdf");
|
||||
|
||||
util_xfree((void**) &str);
|
||||
util_xfree((void **) &str);
|
||||
}
|
||||
|
||||
static void test_str_dup_empty(void** state)
|
||||
static void test_str_dup_empty(void **state)
|
||||
{
|
||||
char* str;
|
||||
char *str;
|
||||
|
||||
str = util_str_dup("");
|
||||
assert_string_equal(str, "");
|
||||
str = util_str_dup("");
|
||||
assert_string_equal(str, "");
|
||||
|
||||
util_xfree((void**) &str);
|
||||
util_xfree((void **) &str);
|
||||
}
|
||||
|
||||
static void test_str_split0(void** state)
|
||||
static void test_str_split0(void **state)
|
||||
{
|
||||
size_t count;
|
||||
char** toks;
|
||||
size_t count;
|
||||
char **toks;
|
||||
|
||||
toks = util_str_split("", ",", &count);
|
||||
toks = util_str_split("", ",", &count);
|
||||
|
||||
assert_int_equal(count, 0);
|
||||
assert_int_equal(count, 0);
|
||||
|
||||
util_str_free_split(toks, count);
|
||||
util_str_free_split(toks, count);
|
||||
}
|
||||
|
||||
static void test_str_split1(void** state)
|
||||
static void test_str_split1(void **state)
|
||||
{
|
||||
size_t count;
|
||||
char** toks;
|
||||
size_t count;
|
||||
char **toks;
|
||||
|
||||
toks = util_str_split("asd", ",", &count);
|
||||
toks = util_str_split("asd", ",", &count);
|
||||
|
||||
assert_int_equal(count, 1);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
assert_int_equal(count, 1);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
|
||||
util_str_free_split(toks, count);
|
||||
util_str_free_split(toks, count);
|
||||
}
|
||||
|
||||
static void test_str_split2(void** state)
|
||||
static void test_str_split2(void **state)
|
||||
{
|
||||
size_t count;
|
||||
char** toks;
|
||||
size_t count;
|
||||
char **toks;
|
||||
|
||||
toks = util_str_split("asd,123", ",", &count);
|
||||
toks = util_str_split("asd,123", ",", &count);
|
||||
|
||||
assert_int_equal(count, 2);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
assert_string_equal(toks[1], "123");
|
||||
assert_int_equal(count, 2);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
assert_string_equal(toks[1], "123");
|
||||
|
||||
util_str_free_split(toks, count);
|
||||
util_str_free_split(toks, count);
|
||||
}
|
||||
|
||||
static void test_str_split3(void** state)
|
||||
static void test_str_split3(void **state)
|
||||
{
|
||||
size_t count;
|
||||
char** toks;
|
||||
size_t count;
|
||||
char **toks;
|
||||
|
||||
toks = util_str_split("/asd/123/ddd/", "/", &count);
|
||||
toks = util_str_split("/asd/123/ddd/", "/", &count);
|
||||
|
||||
assert_int_equal(count, 3);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
assert_string_equal(toks[1], "123");
|
||||
assert_string_equal(toks[2], "ddd");
|
||||
assert_int_equal(count, 3);
|
||||
assert_string_equal(toks[0], "asd");
|
||||
assert_string_equal(toks[1], "123");
|
||||
assert_string_equal(toks[2], "ddd");
|
||||
|
||||
util_str_free_split(toks, count);
|
||||
util_str_free_split(toks, count);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const struct CMUnitTest tests[] ={
|
||||
cmocka_unit_test_setup(test_str_dup, setup),
|
||||
cmocka_unit_test_setup(test_str_dup_empty, setup),
|
||||
cmocka_unit_test_setup(test_str_split0, setup),
|
||||
cmocka_unit_test_setup(test_str_split1, setup),
|
||||
cmocka_unit_test_setup(test_str_split2, setup),
|
||||
cmocka_unit_test_setup(test_str_split3, setup)
|
||||
};
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup(test_str_dup, setup),
|
||||
cmocka_unit_test_setup(test_str_dup_empty, setup),
|
||||
cmocka_unit_test_setup(test_str_split0, setup),
|
||||
cmocka_unit_test_setup(test_str_split1, setup),
|
||||
cmocka_unit_test_setup(test_str_split2, setup),
|
||||
cmocka_unit_test_setup(test_str_split3, setup)};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user