build: re-enable namespace-specific tests
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#include <fx/ds/array.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/collections/array.h>
|
||||
#include <fx/int.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fx_array *array = fx_array_create();
|
||||
fx_array_append(array, FX_RV_INT(32));
|
||||
fx_array_append(array, FX_RV_INT(64));
|
||||
fx_array_append(array, FX_RV_INT(128));
|
||||
fx_array_append(array, fx_int_create(32));
|
||||
fx_array_append(array, fx_int_create(64));
|
||||
fx_array_append(array, fx_int_create(128));
|
||||
|
||||
fx_iterator *it = fx_iterator_begin(array);
|
||||
fx_foreach_ptr(fx_object, obj, it)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/double.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fx_number *number = fx_number_create_float(6.8);
|
||||
fx_double *d = fx_double_create(6.8);
|
||||
|
||||
printf("double=%lf\n", fx_double_get_value(d));
|
||||
fx_double_unref(d);
|
||||
|
||||
printf("number=%zd\n", FX_NUMBER_IVAL(number));
|
||||
fx_number_unref(number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <fx/ds/string.h>
|
||||
#include <fx/string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <fx/core/stream.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <fx/stream.h>
|
||||
#include <fx/string.h>
|
||||
#include <fx/stringstream.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("-------------\n");
|
||||
fx_string *str = fx_string_create_from_cstr("Hello, world!\n");
|
||||
printf("%s\n", fx_string_get_cstr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
|
||||
fx_string_insert_cstr(str, "WOW!", 4);
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", fx_string_get_cstr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
|
||||
fx_string_replace(str, 4, 4, "+");
|
||||
|
||||
printf("-------------\n");
|
||||
printf("%s\n", fx_string_get_cstr(str));
|
||||
printf("len:%zu, max:%zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL),
|
||||
fx_string_get_capacity(str));
|
||||
printf("-------------\n");
|
||||
|
||||
fx_string_unref(str);
|
||||
|
||||
fx_stringstream *strv = fx_stringstream_create();
|
||||
fx_stream_write_cstr(strv, "Hello", NULL);
|
||||
fx_stream_write_cstr(strv, ", world", NULL);
|
||||
fx_stream_write_cstr(strv, "!", NULL);
|
||||
|
||||
char *s = fx_stringstream_steal(strv);
|
||||
fx_stringstream_unref(strv);
|
||||
|
||||
printf("%s\n", s);
|
||||
free(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+14
-11
@@ -1,8 +1,9 @@
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/iterator.h>
|
||||
#include <fx/ds/dict.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/ds/tree.h>
|
||||
#include <fx/bst.h>
|
||||
#include <fx/collections/dict.h>
|
||||
#include <fx/collections/tree.h>
|
||||
#include <fx/int.h>
|
||||
#include <fx/iterator.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NITEMS 16
|
||||
@@ -23,18 +24,20 @@ FX_BST_DEFINE_SIMPLE_INSERT(struct bst_item, node, value, put_node)
|
||||
int main(void)
|
||||
{
|
||||
fx_dict *dict = fx_dict_create();
|
||||
fx_dict_put(dict, "hello", FX_RV_INT(32));
|
||||
fx_dict_put(dict, "world", FX_RV_INT(64));
|
||||
fx_dict_put(dict, "more", FX_RV_INT(128));
|
||||
fx_dict_put(dict, "other", FX_RV_INT(256));
|
||||
fx_dict_put(dict, "hello", fx_int_create(32));
|
||||
fx_dict_put(dict, "world", fx_int_create(64));
|
||||
fx_dict_put(dict, "more", fx_int_create(128));
|
||||
fx_dict_put(dict, "other", fx_int_create(256));
|
||||
|
||||
fx_iterator *it = fx_iterator_begin(dict);
|
||||
|
||||
size_t i = 0;
|
||||
fx_foreach(fx_dict_item *, item, it)
|
||||
{
|
||||
printf("item %zu: %s=%d\n", i++, fx_string_get_cstr(item->key),
|
||||
fx_number_get_int(item->value));
|
||||
printf("item %zu: %s=%" PRIdPTR "\n",
|
||||
i++,
|
||||
fx_string_get_cstr(item->key),
|
||||
fx_int_get_value(item->value));
|
||||
}
|
||||
|
||||
fx_iterator_unref(it);
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("здравс\u26A0твуите\n");
|
||||
fx_string *str = fx_string_create_from_cstr("здравствуите");
|
||||
const char *s = fx_string_get_cstr(str);
|
||||
printf("%s\n", s);
|
||||
printf("len: %zu\n", fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
printf("codepoints: %zu\n", fx_string_get_size(str, FX_STRLEN_CODEPOINTS));
|
||||
|
||||
const char *delims[] = {"в"};
|
||||
size_t nr_delims = sizeof delims / sizeof delims[0];
|
||||
|
||||
fx_iterator *it = fx_string_tokenise(str, delims, nr_delims, 0);
|
||||
fx_foreach(const char *, tok, it)
|
||||
{
|
||||
printf("%s\n", tok);
|
||||
}
|
||||
fx_iterator_unref(it);
|
||||
fx_string_unref(str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
#include <CuTest.h>
|
||||
#include <fx/ds/string.h>
|
||||
|
||||
static void test_string_create(CuTest *tc)
|
||||
{
|
||||
fx_string *str = fx_string_create();
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 0, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "", fx_string_get_cstr(str));
|
||||
|
||||
fx_string_unref(str);
|
||||
|
||||
str = fx_string_create_from_c('A', 8);
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 8, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "AAAAAAAA", fx_string_get_cstr(str));
|
||||
|
||||
fx_string_unref(str);
|
||||
|
||||
str = fx_string_create_from_cstr("Hello, world!");
|
||||
|
||||
CuAssertPtrNotNull(tc, str);
|
||||
CuAssertIntEquals(tc, 13, fx_string_get_size(str, FX_STRLEN_NORMAL));
|
||||
CuAssertStrEquals(tc, "Hello, world!", fx_string_get_cstr(str));
|
||||
|
||||
fx_string_unref(str);
|
||||
}
|
||||
|
||||
static void test_string_length(CuTest *tc)
|
||||
{
|
||||
const char *cstr = "Hello, \033[91;1mworld!";
|
||||
fx_string *s = fx_string_create_from_cstr(cstr);
|
||||
|
||||
CuAssertIntEquals(tc, 13, fx_string_get_size(s, FX_STRLEN_IGNORE_ESC));
|
||||
CuAssertIntEquals(tc, 20, fx_string_get_size(s, FX_STRLEN_NORMAL));
|
||||
|
||||
fx_string_unref(s);
|
||||
}
|
||||
|
||||
CuSuite *get_all_tests(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
||||
SUITE_ADD_TEST(suite, test_string_create);
|
||||
SUITE_ADD_TEST(suite, test_string_length);
|
||||
|
||||
return suite;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <fx/ds/uuid.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
fx_uuid *uuid = fx_uuid_create_from_cstr(
|
||||
"5b80ad1f-367f-4a1f-88f3-b3a6f8d1f63d");
|
||||
char str[FX_UUID_STRING_MAX];
|
||||
fx_uuid_to_cstr(uuid, str);
|
||||
printf("%s\n", str);
|
||||
|
||||
fx_uuid_unref(uuid);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user