diff options
author | justanothercatgirl <sotov2070@gmail.com> | 2024-06-20 14:29:58 +0300 |
---|---|---|
committer | justanothercatgirl <sotov2070@gmail.com> | 2024-06-20 14:29:58 +0300 |
commit | 86263835b2f9727531d8941733df8e05705354bf (patch) | |
tree | dc28138b234b2456cb384b786839f35715f32a66 | |
parent | 3966bcd9601b6871f9e6d08656d517b5e916c77d (diff) |
added tests for an array of pointers
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | tests/obscure.c | 24 |
2 files changed, 27 insertions, 1 deletions
@@ -6,7 +6,7 @@ CFLAGS := -g -Wall -Wextra -Wpedantic -Werror -Wno-language-extension-token tests: dynarray -dynarray: tests/dynarray.c tests/dynarray_struct.c +dynarray: tests/dynarray.c tests/dynarray_struct.c tests/obscure.c $(CC) $(CFLAGS) -o $@ $< -DTT_CHAR ./dynarray $(CC) $(CFLAGS) -o $@ $< -DTT_SHORT @@ -17,6 +17,8 @@ dynarray: tests/dynarray.c tests/dynarray_struct.c ./dynarray $(CC) $(CFLAGS) -o $@ tests/dynarray_struct.c ./dynarray + $(CC) $(CFLAGS) -o $@ tests/obscure.c + ./dynarray rm $@ diff --git a/tests/obscure.c b/tests/obscure.c new file mode 100644 index 0000000..190ff09 --- /dev/null +++ b/tests/obscure.c @@ -0,0 +1,24 @@ +#include <stdio.h> + +#define CONTAINER_IMPLEMENTATION +#include "../include/container.h" + +typedef char* packet_t; + +int main() { + packet_t *data = array_new(packet_t, 0); + packet_t el_0 = malloc(128); + memset(el_0, 42, 128); + packet_t el_1 = malloc(128); + memset(el_1, 69, 128); + array_push(data, el_0); + array_push(data, el_1); + for (size_t i = 0; i < array_size(data); ++i) { + for (size_t j = 0; j < 128; ++j) { + printf("%.2X ", data[i][j]); + } + putchar('\n'); + } + return (data[0][69] == 42 && data[1][42] == 69 ? 0 : 1); + // OS will free it for me +} |