From 86263835b2f9727531d8941733df8e05705354bf Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Thu, 20 Jun 2024 14:29:58 +0300 Subject: added tests for an array of pointers --- tests/obscure.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/obscure.c (limited to 'tests/obscure.c') 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 + +#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 +} -- cgit v1.2.3-70-g09d2