add string type

This commit is contained in:
2026-07-10 04:18:51 -05:00
parent 34b49d6090
commit 96e1a8e0d6
5 changed files with 94 additions and 2 deletions

29
test/string.c Normal file
View File

@@ -0,0 +1,29 @@
#define L_STRING_IMPLEMENTATION
#include "../include/lstring.h"
#include <stdio.h>
int test_l_string() {
int RETURN_CODE = 0;
printf("test_l_string() : ");
int integer_0 = 25;
int integer_1 = 15;
LString* test_string_0 = l_string_new("I would like to purchase item id `%d`", integer_0);
LString* test_string_1 = l_string_new(" for `%d` coins.", integer_1);
if (l_string_cmp(test_string_0, l_string_new("I would like to purchase item id `25`"))) RETURN_CODE++;
if (l_string_cmp(test_string_1, l_string_new(" for `15` coins."))) RETURN_CODE++;
LString* test_string_2 = l_string_new("I would like to purchase item id `25` for `15` coins.");
LString* test_string_3 = l_string_concat(test_string_0, test_string_1);
if (l_string_cmp(test_string_2, test_string_3)) RETURN_CODE++;
l_string_delete(test_string_0);
l_string_delete(test_string_1);
l_string_delete(test_string_2);
l_string_delete(test_string_3);
printf("%d\n", RETURN_CODE);
return RETURN_CODE;
}

View File

@@ -2,10 +2,11 @@
#define L_TYPES_AUTHOR "Lucielle <luci@git.lunarware.tech"
#define L_TYPES_REPO "https://git.lunarware.tech/lucielle/ltypes.git"
#define L_TYPES_VERSION "0.1.1"
#define L_TYPES_VERSION "0.2.0"
#define L_TYPES_LICENSE "GNU GPL v3"
int test_l_array();
int test_l_string();
int main(void) {
printf("AUTHOR: %s\n", L_TYPES_AUTHOR);
@@ -16,6 +17,7 @@ int main(void) {
int RETURN_CODE = 0;
RETURN_CODE += test_l_array();
RETURN_CODE += test_l_string();
printf("\nError Total: %d\n", RETURN_CODE);
return RETURN_CODE;