add string type
This commit is contained in:
29
test/string.c
Normal file
29
test/string.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user