refactor(test): remove relative include

This commit is contained in:
2025-09-12 03:54:30 +02:00
parent 55ca92414f
commit ff90146aee
9 changed files with 40 additions and 25 deletions

View File

@@ -11,23 +11,23 @@ cc = meson.get_compiler('c')
lib_src = files( lib_src = files(
'hashmap/myhashmap.c', 'hashmap/myhashmap.c',
'queue/myqueue.c', 'queue/myqueue.c',
'socket/mysocket.c',
'stack/mystack.c',
'string/mystring.c', 'string/mystring.c',
'vector/myvector.c', 'vector/myvector.c',
'stack/mystack.c',
'socket/mysocket.c',
) )
# Test files # Test files
test_src = files( test_src = files(
'test/test.c',
'test/hashmap/hm1.c', 'test/hashmap/hm1.c',
'test/queue/queue1.c', 'test/queue/queue1.c',
'test/socket/socket1.c',
'test/stack/stack1.c',
'test/string/str1.c', 'test/string/str1.c',
'test/string/str2.c', 'test/string/str2.c',
'test/string/str3.c', 'test/string/str3.c',
'test/test.c',
'test/vector/vec1.c', 'test/vector/vec1.c',
'test/stack/stack1.c',
'test/socket/socket1.c',
) )
# Windows Socket lib # Windows Socket lib
@@ -35,12 +35,35 @@ winsock_dep = cc.find_library('ws2_32', required: false)
# Include directories # Include directories
inc_dir = include_directories('string', 'queue', 'hashmap', 'vector', 'stack', 'socket') inc_dir = include_directories('string', 'queue', 'hashmap', 'vector', 'stack', 'socket')
win_inc_dir = include_directories('c:/include/')
# Static library # Static library
myclib_lib = static_library('myclib', lib_src, include_directories: inc_dir, dependencies: winsock_dep, install: true) myclib_lib = static_library(
'myclib',
lib_src,
include_directories: inc_dir,
dependencies: winsock_dep,
install: true,
)
# Install headers # Install headers
install_headers(['hashmap/myhashmap.h', 'queue/myqueue.h', 'string/mystring.h', 'vector/myvector.h', 'stack/mystack.h', 'socket/mysocket.h'], subdir: 'myclib') install_headers(
[
'hashmap/myhashmap.h',
'queue/myqueue.h',
'string/mystring.h',
'vector/myvector.h',
'stack/mystack.h',
'socket/mysocket.h',
],
subdir: 'myclib',
)
# Test executable # Test executable
executable('testlib', lib_src + test_src, include_directories: inc_dir, dependencies: winsock_dep) executable(
'testlib',
lib_src + test_src,
include_directories: [inc_dir, win_inc_dir],
dependencies: winsock_dep,
link_with: myclib_lib,
)

View File

@@ -1,10 +1,9 @@
#include <assert.h> #include <assert.h>
#include <myclib/myhashmap.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../../hashmap/myhashmap.h"
#define MAX_STR_LEN 64 #define MAX_STR_LEN 64
/* My custom data type stored as value */ /* My custom data type stored as value */

View File

@@ -1,6 +1,5 @@
#include <assert.h> #include <assert.h>
#include <myclib/myqueue.h>
#include "../../queue/myqueue.h"
void test_queue1(void) { void test_queue1(void) {
/* Allocate a new queue */ /* Allocate a new queue */

View File

@@ -1,8 +1,7 @@
#include <myclib/mysocket.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "../../socket/mysocket.h"
void test_socket1(void) { void test_socket1(void) {
sock_platform_init(); sock_platform_init();
struct addrinfo hints, *res, *p; struct addrinfo hints, *res, *p;

View File

@@ -1,8 +1,7 @@
#include <assert.h> #include <assert.h>
#include <myclib/mystack.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../stack/mystack.h"
void test_stack1(void) { void test_stack1(void) {
stack_s *stack = stack_new(32, sizeof(int)); stack_s *stack = stack_new(32, sizeof(int));
int num = 10; int num = 10;

View File

@@ -1,10 +1,9 @@
#include <assert.h> #include <assert.h>
#include <myclib/mystring.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../../string/mystring.h"
void test_str1(void) { void test_str1(void) {
size_t length; size_t length;
size_t capacity; size_t capacity;

View File

@@ -1,8 +1,7 @@
#include <assert.h> #include <assert.h>
#include <myclib/mystring.h>
#include <string.h> #include <string.h>
#include "../../string/mystring.h"
void test_str2(void) { void test_str2(void) {
string_s *s1 = string_new("Hello, world!", 0); string_s *s1 = string_new("Hello, world!", 0);
assert(s1 != NULL); assert(s1 != NULL);

View File

@@ -1,8 +1,7 @@
#include <assert.h> #include <assert.h>
#include <myclib/mystring.h>
#include <string.h> #include <string.h>
#include "../../string/mystring.h"
void test_str3(void) { void test_str3(void) {
/* Make a new string from format */ /* Make a new string from format */
string_s *s = string_format("My name is %s (%d)", "John", 21); string_s *s = string_format("My name is %s (%d)", "John", 21);

View File

@@ -1,8 +1,7 @@
#include <assert.h> #include <assert.h>
#include <myclib/myvector.h>
#include <stdlib.h> #include <stdlib.h>
#include "../../vector/myvector.h"
typedef struct my_elem { typedef struct my_elem {
char name[32]; char name[32];
int age; int age;