diff --git a/include/neo.h b/include/neo.h index 3ed314d..2c1e61d 100644 --- a/include/neo.h +++ b/include/neo.h @@ -13,9 +13,9 @@ extern "C" { #include "neo/_error.h" #include "neo/_nbuf.h" #include "neo/_nref.h" +#include "neo/_nstr.h" #include "neo/_types.h" #include "neo/_stddef.h" -#include "neo/_string.h" #include "neo/_nalloc.h" #ifdef __cplusplus diff --git a/include/neo/_error.h b/include/neo/_error.h index 5ebdb01..b93d412 100644 --- a/include/neo/_error.h +++ b/include/neo/_error.h @@ -18,7 +18,7 @@ * the values to insert which will become the error message. */ __attribute__(( __format__(printf, 3, 4) )) -void yeet(error *err, u32 number, const char *__restrict fmt, ...); +void yeet(error *err, u32 number, const char *restrict fmt, ...); /** * Indicate an operation has completed successfully. @@ -62,7 +62,7 @@ void errput(error *err); * Get an optional error message, this may be `nil` * Must only be used within a catch block and before `errput` is called. */ -#define errmsg(err) ((err) == nil ? (string *)nil : (err)->_message) +#define errmsg(err) ((err) == nil ? (nstr_t *)nil : (err)->_message) /* * This file is part of libneo. diff --git a/include/neo/_string.h b/include/neo/_nstr.h similarity index 90% rename from include/neo/_string.h rename to include/neo/_nstr.h index 5985199..620c321 100644 --- a/include/neo/_string.h +++ b/include/neo/_nstr.h @@ -12,7 +12,7 @@ * `src/string/nstr.c` for details. */ struct _neo_nstr_init_info { - string **dest; + nstr_t **dest; const char *data; }; @@ -25,7 +25,7 @@ struct _neo_nstr_init_info { * @param content: A `const char *` with the contents of the string */ #define NSTR_DEFINE(name, content) \ - string *name = nil; \ + nstr_t *name = nil; \ __neo_section(.data.__neo.nstr_array) \ struct _neo_nstr_init_info __neo_nstr_init_info_##name = { \ .dest = &name, \ @@ -43,7 +43,7 @@ struct _neo_nstr_init_info { * @param err: Error pointer * @returns The converted string, unless an error occurred */ -string *nstr(const char *restrict s, error *err); +nstr_t *nstr(const char *restrict s, error *err); /** * Copy a regular C string to a neo string, but at most `maxsize` bytes. @@ -57,7 +57,7 @@ string *nstr(const char *restrict s, error *err); * @param err: Error pointer * @returns The converted string, unless an error occurred */ -string *nnstr(const char *restrict s, usize maxsize, error *err); +nstr_t *nnstr(const char *restrict s, usize maxsize, error *err); /** * Get the Unicode code point in a string at the specified index. @@ -70,7 +70,7 @@ string *nnstr(const char *restrict s, usize maxsize, error *err); * @returns The Unicode code point at the specified index, * unless an error occurred */ -nchar nchrat(const string *s, usize index, error *err); +nchar nchrat(const nstr_t *s, usize index, error *err); /** * Convert a signed integer to a string. @@ -82,7 +82,7 @@ nchar nchrat(const string *s, usize index, error *err); * @param err: Error pointer * @returns The stringified integer, unless an error occurred */ -string *i2nstr(i64 i, int radix, error *err); +nstr_t *i2nstr(i64 i, int radix, error *err); /** * Convert an unsigned integer to a string. @@ -94,7 +94,7 @@ string *i2nstr(i64 i, int radix, error *err); * @param err: Error pointer * @returns The stringified integer, unless an error occurred */ -string *u2nstr(u64 u, int radix, error *err); +nstr_t *u2nstr(u64 u, int radix, error *err); /** * Duplicate a string. @@ -106,7 +106,7 @@ string *u2nstr(u64 u, int radix, error *err); * @param err: Error pointer * @returns The duplicated string, unless an error occurred */ -string *nstrdup(const string *s, error *err); +nstr_t *nstrdup(const nstr_t *s, error *err); /** * Repeat a string `n` times and return the new string. @@ -120,7 +120,7 @@ string *nstrdup(const string *s, error *err); * @param err: Error pointer * @returns A new string with the repeated content, unless an error occurred */ -string *nstrmul(const string *s, usize n, error *err); +nstr_t *nstrmul(const nstr_t *s, usize n, error *err); /** * Create a string considting of `n` repetitions of `c`. @@ -133,7 +133,7 @@ string *nstrmul(const string *s, usize n, error *err); * @param err: Error pointer * @returns The string, unless an error occurred */ -string *nchrmul(nchar c, usize n, error *err); +nstr_t *nchrmul(nchar c, usize n, error *err); /** * Concatenate two strings and return the result. @@ -147,7 +147,7 @@ string *nchrmul(nchar c, usize n, error *err); * @returns A new string instance that consists of the two concatenated ones, * unless an error occurred */ -string *nstrcat(const string *s1, const string *s2, error *err); +nstr_t *nstrcat(const nstr_t *s1, const nstr_t *s2, error *err); /** * Compare two strings character by character. @@ -159,7 +159,7 @@ string *nstrcat(const string *s1, const string *s2, error *err); * @param err: Error pointer * @returns The difference between the two strings, unless an error occurred */ -int nstrcmp(const string *s1, const string *s2, error *err); +int nstrcmp(const nstr_t *s1, const nstr_t *s2, error *err); /** * Determine whether two strings are exactly equal. @@ -185,7 +185,7 @@ int nstrcmp(const string *s1, const string *s2, error *err); * @param err: Error pointer * @returns The new padded string */ -string *leftpad(const string *s, usize length, nchar fill, error *err); +nstr_t *leftpad(const nstr_t *s, usize length, nchar fill, error *err); /** * Iterate over each character in a string. diff --git a/include/neo/_types.h b/include/neo/_types.h index 3a4898e..3711d7e 100644 --- a/include/neo/_types.h +++ b/include/neo/_types.h @@ -74,7 +74,7 @@ struct _neo_nbuf { */ typedef struct _neo_nbuf nbuf_t; -struct _neo_string { +struct _neo_nstr { /* The *amount of Unicode code points*, NOT amount of bytes */ NLEN_FIELD(_len); NREF_FIELD; @@ -82,10 +82,10 @@ struct _neo_string { usize _size; char *_data; }; -typedef struct _neo_string string; +typedef struct _neo_nstr nstr_t; struct _neo_error { - string *_message; + nstr_t *_message; u32 _number; }; typedef struct _neo_error error; diff --git a/include/neo/utf.h b/include/neo/utf.h index efb39bc..c424fee 100644 --- a/include/neo/utf.h +++ b/include/neo/utf.h @@ -33,7 +33,7 @@ extern "C" { * @returns The number of UTF-8 code points (i.e. number of Unicode characters) * excluding the terminating NUL byte; undefined on error */ -usize utf8_check(const char *__restrict s, error *err); +usize utf8_check(const char *restrict s, error *err); /** * Check whether a NUL terminated string is valid UTF-8, but read at most @@ -49,7 +49,7 @@ usize utf8_check(const char *__restrict s, error *err); * @returns The number of UTF-8 code points (i.e. number of Unicode characters) * excluding the terminating NUL byte; undefined on error */ -usize utf8_ncheck(const char *__restrict s, usize maxsize, error *err); +usize utf8_ncheck(const char *restrict s, usize maxsize, error *err); /** * Compute the length of a raw UTF-8 encoded, NUL terminated string. @@ -61,7 +61,7 @@ usize utf8_ncheck(const char *__restrict s, usize maxsize, error *err); * @returns: String length as in Unicode code points (not bytes), * excluding the terminating NUL byte */ -usize utf8_strlen(const char *__restrict s); +usize utf8_strlen(const char *restrict s); /** * Get the amount of bytes a Unicode character takes up in UTF-8. @@ -89,7 +89,7 @@ usize utf8_chrsize(nchar c, error *err); * @returns The amount of bytes taken up by the character, * which is always between 1 and 4 except on errors */ -usize utf8_from_nchr(char *__restrict dest, nchar c, error *err); +usize utf8_from_nchr(char *restrict dest, nchar c, error *err); /** * Decode a UTF-8 character and store it in `c`. @@ -107,7 +107,7 @@ usize utf8_from_nchr(char *__restrict dest, nchar c, error *err); * @returns The amount of bytes the character took up when encoded as UTF-8, * which is always between 1 and 4 except on errors */ -usize utf8_to_nchr(nchar *c, const char *__restrict utf8chr, error *err); +usize utf8_to_nchr(nchar *c, const char *restrict utf8chr, error *err); #ifdef __cplusplus }; /* extern "C" */ diff --git a/src/error.c b/src/error.c index 469ff84..1a236a3 100644 --- a/src/error.c +++ b/src/error.c @@ -9,8 +9,8 @@ #include "neo/_error.h" #include "neo/_nalloc.h" #include "neo/_nref.h" +#include "neo/_nstr.h" #include "neo/_stddef.h" -#include "neo/_string.h" #include "neo/_types.h" void yeet(error *err, u32 number, const char *restrict fmt, ...) diff --git a/src/string/leftpad.c b/src/string/leftpad.c index 5f5047a..abaee8d 100644 --- a/src/string/leftpad.c +++ b/src/string/leftpad.c @@ -6,11 +6,11 @@ #include "neo/_error.h" #include "neo/_nalloc.h" #include "neo/_nref.h" -#include "neo/_string.h" +#include "neo/_nstr.h" #include "neo/_types.h" #include "neo/utf.h" -static inline string *leftpad_unsafe(const string *s, usize len, nchar fillchr, error *err) +static inline nstr_t *leftpad_unsafe(const nstr_t *s, usize len, nchar fillchr, error *err) { char utf8_fillchr[5]; usize fillchr_size = utf8_from_nchr(&utf8_fillchr[0], fillchr, err); @@ -39,7 +39,7 @@ static inline string *leftpad_unsafe(const string *s, usize len, nchar fillchr, } strcpy(pos, s->_data); - string *padded = nstr(dest, err); + nstr_t *padded = nstr(dest, err); catch(err) { padded = nil; } @@ -47,14 +47,14 @@ static inline string *leftpad_unsafe(const string *s, usize len, nchar fillchr, return padded; } -string *leftpad(const string *s, usize len, nchar fillchr, error *err) +nstr_t *leftpad(const nstr_t *s, usize len, nchar fillchr, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); return 0; } - string *padded; + nstr_t *padded; if (len < nlen(s)) { yeet(err, ERANGE, "String is longer than requested length"); diff --git a/src/string/nstr.c b/src/string/nstr.c index 127a74f..fa99e42 100644 --- a/src/string/nstr.c +++ b/src/string/nstr.c @@ -9,25 +9,25 @@ #include "neo/_error.h" #include "neo/_nalloc.h" #include "neo/_nref.h" -#include "neo/_string.h" +#include "neo/_nstr.h" #include "neo/_toolchain.h" #include "neo/_types.h" #include "neo/utf.h" -static void nstr_destroy(string *str) +static void nstr_destroy(nstr_t *str) { nfree(str->_data); nfree(str); } -static string *nstr_unsafe(const char *restrict s, usize size_without_nul, error *err) +static nstr_t *nstr_unsafe(const char *restrict s, usize size_without_nul, error *err) { usize len = utf8_ncheck(s, size_without_nul, err); catch(err) { return nil; } - string *str = nalloc(sizeof(*str), err); + nstr_t *str = nalloc(sizeof(*str), err); catch(err) { return nil; } @@ -64,7 +64,7 @@ static string *nstr_unsafe(const char *restrict s, usize size_without_nul, error return str; } -string *nstr(const char *restrict s, error *err) +nstr_t *nstr(const char *restrict s, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); @@ -75,7 +75,7 @@ string *nstr(const char *restrict s, error *err) return nstr_unsafe(s, size_without_nul, err); } -string *nnstr(const char *restrict s, usize maxsize, error *err) +nstr_t *nnstr(const char *restrict s, usize maxsize, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); @@ -86,7 +86,7 @@ string *nnstr(const char *restrict s, usize maxsize, error *err) return nstr_unsafe(s, size_without_nul, err); } -nchar nchrat(const string *s, usize index, error *err) +nchar nchrat(const nstr_t *s, usize index, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); diff --git a/src/string/nstrcat.c b/src/string/nstrcat.c index bfe1b96..9ac6c38 100644 --- a/src/string/nstrcat.c +++ b/src/string/nstrcat.c @@ -9,11 +9,11 @@ #include "neo/_error.h" #include "neo/_nalloc.h" #include "neo/_nref.h" +#include "neo/_nstr.h" #include "neo/_stddef.h" -#include "neo/_string.h" #include "neo/_types.h" -string *nstrcat(const string *s1, const string *s2, error *err) +nstr_t *nstrcat(const nstr_t *s1, const nstr_t *s2, error *err) { if (s1 == nil) { yeet(err, EFAULT, "First string is nil"); @@ -36,7 +36,7 @@ string *nstrcat(const string *s1, const string *s2, error *err) memcpy(cat + s1_size_without_nul, s2->_data, s2_size_without_nul); cat[s1_size_without_nul + s2_size_without_nul] = '\0'; - string *ret = nstr(cat, err); + nstr_t *ret = nstr(cat, err); nfree(cat); return ret; } diff --git a/src/string/nstrcmp.c b/src/string/nstrcmp.c index cfd97d3..ba5edbc 100644 --- a/src/string/nstrcmp.c +++ b/src/string/nstrcmp.c @@ -5,11 +5,11 @@ #include "neo/_error.h" #include "neo/_nref.h" +#include "neo/_nstr.h" #include "neo/_stddef.h" -#include "neo/_string.h" #include "neo/_types.h" -int nstrcmp(const string *s1, const string *s2, error *err) +int nstrcmp(const nstr_t *s1, const nstr_t *s2, error *err) { /* * Return values are always undefined if an error was yeeted so it's not diff --git a/src/string/nstrdup.c b/src/string/nstrdup.c index fd1bfd9..34c1bc2 100644 --- a/src/string/nstrdup.c +++ b/src/string/nstrdup.c @@ -3,10 +3,10 @@ #include #include "neo/_error.h" -#include "neo/_string.h" +#include "neo/_nstr.h" #include "neo/_types.h" -string *nstrdup(const string *s, error *err) +nstr_t *nstrdup(const nstr_t *s, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); diff --git a/src/string/nstrmul.c b/src/string/nstrmul.c index 4f20bf1..114e27d 100644 --- a/src/string/nstrmul.c +++ b/src/string/nstrmul.c @@ -6,12 +6,12 @@ #include "neo/_error.h" #include "neo/_nalloc.h" #include "neo/_nref.h" +#include "neo/_nstr.h" #include "neo/_stddef.h" -#include "neo/_string.h" #include "neo/_types.h" #include "neo/utf.h" -string *nstrmul(const string *s, usize n, error *err) +nstr_t *nstrmul(const nstr_t *s, usize n, error *err) { if (s == nil) { yeet(err, EFAULT, "String is nil"); @@ -34,12 +34,12 @@ string *nstrmul(const string *s, usize n, error *err) pos += s_size; } - string *ret = nstr(multiplied, err); + nstr_t *ret = nstr(multiplied, err); nfree(multiplied); return ret; } -string *nchrmul(nchar c, usize n, error *err) +nstr_t *nchrmul(nchar c, usize n, error *err) { if (n == 0) return nstr("", err); @@ -61,7 +61,7 @@ string *nchrmul(nchar c, usize n, error *err) pos += s_size; } - string *ret = nstr(multiplied, err); + nstr_t *ret = nstr(multiplied, err); nfree(multiplied); return ret; } diff --git a/src/string/x2nstr.c b/src/string/x2nstr.c index f7d68d2..849cb58 100644 --- a/src/string/x2nstr.c +++ b/src/string/x2nstr.c @@ -3,7 +3,7 @@ #include #include "neo/_error.h" -#include "neo/_string.h" +#include "neo/_nstr.h" #include "neo/_types.h" static char *unsigned_convert(char *end, u64 n, int radix, error *err) @@ -31,7 +31,7 @@ static char *unsigned_convert(char *end, u64 n, int radix, error *err) return end; } -string *u2nstr(u64 n, int radix, error *err) +nstr_t *u2nstr(u64 n, int radix, error *err) { char buf[65]; char *s = unsigned_convert(&buf[64], n, radix, err); @@ -41,7 +41,7 @@ string *u2nstr(u64 n, int radix, error *err) return nstr(s, err); } -string *i2nstr(i64 n, int radix, error *err) +nstr_t *i2nstr(i64 n, int radix, error *err) { char buf[66]; diff --git a/test/nbuf.cpp b/test/nbuf.cpp index fd44cf7..2f44ed8 100644 --- a/test/nbuf.cpp +++ b/test/nbuf.cpp @@ -20,7 +20,7 @@ TEST_CASE( "nbuf_create: Error if size is 0", "[src/nbuf.c]" ) { error err; nbuf_t *buf = nbuf_create(0, &err); - string *expected_msg = nstr("Cannot create zero-size buffer", nil); + nstr_t *expected_msg = nstr("Cannot create zero-size buffer", nil); REQUIRE( buf == nil ); REQUIRE( errnum(&err) == ERANGE ); @@ -49,7 +49,7 @@ TEST_CASE( "nbuf_from: Error if data is nil", "[src/nbuf.c]" ) error err; nbuf_t *buf = nbuf_from(nil, 1, &err); - string *expected_msg = nstr("Data is nil", nil); + nstr_t *expected_msg = nstr("Data is nil", nil); REQUIRE( buf == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -65,7 +65,7 @@ TEST_CASE( "nbuf_from: Error if size is 0", "[src/nbuf.c]" ) const char *data = "i'm gay,,,"; nbuf_t *buf = nbuf_from(data, 0, &err); - string *expected_msg = nstr("Cannot create zero-size buffer", nil); + nstr_t *expected_msg = nstr("Cannot create zero-size buffer", nil); REQUIRE( buf == nil ); REQUIRE( errnum(&err) == ERANGE ); @@ -98,7 +98,7 @@ TEST_CASE( "nbuf_clone: Error if original buffer is nil", "[src/nbuf.c]" ) error err; nbuf_t *buf = nbuf_clone(nil, &err); - string *expected_msg = nstr("Source buffer is nil", nil); + nstr_t *expected_msg = nstr("Source buffer is nil", nil); REQUIRE( buf == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -171,7 +171,7 @@ TEST_CASE( "nbuf_cmp: Error if first buffer is nil", "[src/nbuf.c]" ) nbuf_t *buf2 = nbuf_from(data, size, nil); int diff = nbuf_cmp(nil, buf2, &err); - string *expected_msg = nstr("First buffer is nil", nil); + nstr_t *expected_msg = nstr("First buffer is nil", nil); REQUIRE( diff < 0 ); REQUIRE( errnum(&err) == EFAULT ); @@ -190,7 +190,7 @@ TEST_CASE( "nbuf_cmp: Error if second buffer is nil", "[src/nbuf.c]" ) nbuf_t *buf1 = nbuf_from(data, size, nil); int diff = nbuf_cmp(buf1, nil, &err); - string *expected_msg = nstr("Second buffer is nil", nil); + nstr_t *expected_msg = nstr("Second buffer is nil", nil); REQUIRE( diff > 0 ); REQUIRE( errnum(&err) == EFAULT ); @@ -206,7 +206,7 @@ TEST_CASE( "nbuf_cmp: Error if both buffers are nil", "[src/nbuf.c]" ) int diff = nbuf_cmp(nil, nil, &err); - string *expected_msg = nstr("First buffer is nil", nil); + nstr_t *expected_msg = nstr("First buffer is nil", nil); REQUIRE( diff == 0 ); REQUIRE( errnum(&err) == EFAULT ); diff --git a/test/string/i2nstr.cpp b/test/string/i2nstr.cpp index ada4343..1665718 100644 --- a/test/string/i2nstr.cpp +++ b/test/string/i2nstr.cpp @@ -9,8 +9,8 @@ TEST_CASE( "i2nstr: Convert 0 to base 2", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("0", nil); - string *actual = i2nstr(0, 2, &err); + nstr_t *expected = nstr("0", nil); + nstr_t *actual = i2nstr(0, 2, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -24,8 +24,8 @@ TEST_CASE( "i2nstr: Convert 0 to base 36", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("0", nil); - string *actual = i2nstr(0, 36, &err); + nstr_t *expected = nstr("0", nil); + nstr_t *actual = i2nstr(0, 36, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -39,8 +39,8 @@ TEST_CASE( "i2nstr: Convert 255 to base 2", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("11111111", nil); - string *actual = i2nstr(255, 2, &err); + nstr_t *expected = nstr("11111111", nil); + nstr_t *actual = i2nstr(255, 2, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -54,8 +54,8 @@ TEST_CASE( "i2nstr: Convert -255 to base 2", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("-11111111", nil); - string *actual = i2nstr(-255, 2, &err); + nstr_t *expected = nstr("-11111111", nil); + nstr_t *actual = i2nstr(-255, 2, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -69,8 +69,8 @@ TEST_CASE( "i2nstr: Convert 1679615 to base 36", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("zzzz", nil); - string *actual = i2nstr(1679615, 36, &err); + nstr_t *expected = nstr("zzzz", nil); + nstr_t *actual = i2nstr(1679615, 36, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -84,8 +84,8 @@ TEST_CASE( "i2nstr: Convert -1679615 to base 36", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("-zzzz", nil); - string *actual = i2nstr(-1679615, 36, &err); + nstr_t *expected = nstr("-zzzz", nil); + nstr_t *actual = i2nstr(-1679615, 36, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -99,8 +99,8 @@ TEST_CASE( "i2nstr: Convert 2^63-1 to base 16", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("7fffffffffffffff", nil); - string *actual = i2nstr(0x7fffffffffffffff, 16, &err); + nstr_t *expected = nstr("7fffffffffffffff", nil); + nstr_t *actual = i2nstr(0x7fffffffffffffff, 16, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -114,8 +114,8 @@ TEST_CASE( "i2nstr: Convert -2^63 to base 16", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("-8000000000000000", nil); - string *actual = i2nstr(-0x8000000000000000, 16, &err); + nstr_t *expected = nstr("-8000000000000000", nil); + nstr_t *actual = i2nstr(-0x8000000000000000, 16, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -128,10 +128,10 @@ TEST_CASE( "i2nstr: Convert -2^63 to base 16", "[string/x2nstr.c]" ) TEST_CASE( "i2nstr: Error if base too low", "[string/x2nstr.c]" ) { error err; - string *s = i2nstr(420, 1, &err); + nstr_t *s = i2nstr(420, 1, &err); - string *expected_msg = nstr("Numerical base out of range", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Numerical base out of range", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( s == nil ); REQUIRE( nstreq(expected_msg, actual_msg, nil) ); @@ -144,10 +144,10 @@ TEST_CASE( "i2nstr: Error if base too low", "[string/x2nstr.c]" ) TEST_CASE( "i2nstr: Error if base too high", "[string/x2nstr.c]" ) { error err; - string *s = i2nstr(420, 37, &err); + nstr_t *s = i2nstr(420, 37, &err); - string *expected_msg = nstr("Numerical base out of range", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Numerical base out of range", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( s == nil ); REQUIRE( nstreq(expected_msg, actual_msg, nil) ); diff --git a/test/string/leftpad.cpp b/test/string/leftpad.cpp index 027cabb..fe5a2c1 100644 --- a/test/string/leftpad.cpp +++ b/test/string/leftpad.cpp @@ -8,10 +8,10 @@ TEST_CASE( "leftpad: Pad a string with ASCII character", "[string/leftpad.c]" ) { error err; - string *s = nstr("i'm gay,,,", nil); + nstr_t *s = nstr("i'm gay,,,", nil); - string *expected = nstr(",,,i'm gay,,,", nil); - string *actual = leftpad(s, 13, ',', &err); + nstr_t *expected = nstr(",,,i'm gay,,,", nil); + nstr_t *actual = leftpad(s, 13, ',', &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 13 ); @@ -26,10 +26,10 @@ TEST_CASE( "leftpad: Pad a string with ASCII character", "[string/leftpad.c]" ) TEST_CASE( "leftpad: Pad a string with UTF-8 character", "[string/leftpad.c]" ) { error err; - string *s = nstr("i'm gay,,,", nil); + nstr_t *s = nstr("i'm gay,,,", nil); - string *expected = nstr("\xf0\x9f\xa5\xba\xf0\x9f\xa5\xbai'm gay,,,", nil); - string *actual = leftpad(s, 12, 0x01f97a, &err); + nstr_t *expected = nstr("\xf0\x9f\xa5\xba\xf0\x9f\xa5\xbai'm gay,,,", nil); + nstr_t *actual = leftpad(s, 12, 0x01f97a, &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 12 ); @@ -44,9 +44,9 @@ TEST_CASE( "leftpad: Pad a string with UTF-8 character", "[string/leftpad.c]" ) TEST_CASE( "leftpad: Duplicate if string is expected length", "[string/leftpad.c]" ) { error err; - string *s = nstr("i'm gay,,,", nil); + nstr_t *s = nstr("i'm gay,,,", nil); - string *padded = leftpad(s, 10, ',', &err); + nstr_t *padded = leftpad(s, 10, ',', &err); REQUIRE( padded != nil ); REQUIRE( nlen(padded) == 10 ); @@ -60,9 +60,9 @@ TEST_CASE( "leftpad: Duplicate if string is expected length", "[string/leftpad.c TEST_CASE( "leftpad: Error if string is nil", "[string/leftpad.c]" ) { error err; - string *s = leftpad(nil, 10, ',', &err); + nstr_t *s = leftpad(nil, 10, ',', &err); - string *expected_msg = nstr("String is nil", nil); + nstr_t *expected_msg = nstr("String is nil", nil); REQUIRE( s == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -75,10 +75,10 @@ TEST_CASE( "leftpad: Error if string is nil", "[string/leftpad.c]" ) TEST_CASE( "leftpad: Error if string is too long", "[string/leftpad.c]" ) { error err; - string *s = nstr("i'm gay,,,", nil); - string *padded = leftpad(s, 9, ',', &err); + nstr_t *s = nstr("i'm gay,,,", nil); + nstr_t *padded = leftpad(s, 9, ',', &err); - string *expected_msg = nstr("String is longer than requested length", nil); + nstr_t *expected_msg = nstr("String is longer than requested length", nil); REQUIRE( padded == nil ); REQUIRE( errnum(&err) == ERANGE ); diff --git a/test/string/nstr.cpp b/test/string/nstr.cpp index 812ad5a..9bb8edd 100644 --- a/test/string/nstr.cpp +++ b/test/string/nstr.cpp @@ -8,7 +8,7 @@ TEST_CASE( "nstr: Create a string", "[string/nstr.c]" ) { error err; - string *s = nstr("i'm gay,,,", &err); + nstr_t *s = nstr("i'm gay,,,", &err); REQUIRE( s != nil ); REQUIRE( nlen(s) == 10 ); @@ -21,10 +21,10 @@ TEST_CASE( "nstr: Create a string", "[string/nstr.c]" ) TEST_CASE( "nstr: Error if raw strig is nil", "[string/nstr,c]") { error err; - string *s = nstr(nil, &err); + nstr_t *s = nstr(nil, &err); - string *expected = nstr("String is nil", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("String is nil", nil); + nstr_t *actual = errmsg(&err); REQUIRE( s == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -36,7 +36,7 @@ TEST_CASE( "nnstr: Create a string", "[string/nstr.c]" ) { error err; /* 10 character string, must be truncated */ - string *s = nnstr("i'm gay,,,", 8, &err); + nstr_t *s = nnstr("i'm gay,,,", 8, &err); REQUIRE( s != nil ); REQUIRE( nlen(s) == 8 ); @@ -49,10 +49,10 @@ TEST_CASE( "nnstr: Create a string", "[string/nstr.c]" ) TEST_CASE( "nnstr: Error if raw strig is nil", "[string/nstr,c]") { error err; - string *s = nnstr(nil, 10, &err); + nstr_t *s = nnstr(nil, 10, &err); - string *expected = nstr("String is nil", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("String is nil", nil); + nstr_t *actual = errmsg(&err); REQUIRE( s == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -64,7 +64,7 @@ NSTR_DEFINE(static_test_string_1, "i'm gay,,,"); TEST_CASE( "_neo_nstr_init_array: Statically initialize ASCII string", "[string/nstr.c]" ) { - string *expected_s1 = nstr("i'm gay,,,", nil); + nstr_t *expected_s1 = nstr("i'm gay,,,", nil); REQUIRE( nstreq(expected_s1, static_test_string_1, nil) ); REQUIRE( nlen(static_test_string_1) == 10 ); @@ -74,7 +74,7 @@ NSTR_DEFINE(static_test_string_2, "i'm gay\xf0\x9f\xa5\xba,,,"); TEST_CASE( "_neo_nstr_init_array: Statically initialize UTF-8 string", "[string/nstr.c]" ) { - string *expected_s2 = nstr("i'm gay\xf0\x9f\xa5\xba,,,", nil); + nstr_t *expected_s2 = nstr("i'm gay\xf0\x9f\xa5\xba,,,", nil); REQUIRE( nstreq(expected_s2, static_test_string_2, nil) ); REQUIRE( nlen(static_test_string_2) == 11 ); diff --git a/test/string/nstrcat.cpp b/test/string/nstrcat.cpp index 79b8791..118ae92 100644 --- a/test/string/nstrcat.cpp +++ b/test/string/nstrcat.cpp @@ -8,10 +8,10 @@ TEST_CASE( "nstrcat: Concatenate two strings", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("i'm ", nil); - string *s2 = nstr("gay,,,", nil); - string *expected = nstr("i'm gay,,,", nil); - string *actual = nstrcat(s1, s2, &err); + nstr_t *s1 = nstr("i'm ", nil); + nstr_t *s2 = nstr("gay,,,", nil); + nstr_t *expected = nstr("i'm gay,,,", nil); + nstr_t *actual = nstrcat(s1, s2, &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 10 ); @@ -27,10 +27,10 @@ TEST_CASE( "nstrcat: Concatenate two strings", "[string/nstrcat.c]" ) TEST_CASE( "nstrcat: Concatenate two UTF-8 strings", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("i'm ", nil); - string *s2 = nstr("gay\xf0\x9f\xa5\xba,,,", nil); - string *expected = nstr("i'm gay\xf0\x9f\xa5\xba,,,", nil); - string *actual = nstrcat(s1, s2, &err); + nstr_t *s1 = nstr("i'm ", nil); + nstr_t *s2 = nstr("gay\xf0\x9f\xa5\xba,,,", nil); + nstr_t *expected = nstr("i'm gay\xf0\x9f\xa5\xba,,,", nil); + nstr_t *actual = nstrcat(s1, s2, &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 11 ); @@ -46,10 +46,10 @@ TEST_CASE( "nstrcat: Concatenate two UTF-8 strings", "[string/nstrcat.c]" ) TEST_CASE( "nstrcat: Concatenate two empty strings", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("", nil); - string *s2 = nstr("", nil); - string *expected = nstr("", nil); - string *actual = nstrcat(s1, s2, &err); + nstr_t *s1 = nstr("", nil); + nstr_t *s2 = nstr("", nil); + nstr_t *expected = nstr("", nil); + nstr_t *actual = nstrcat(s1, s2, &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 0 ); @@ -65,11 +65,11 @@ TEST_CASE( "nstrcat: Concatenate two empty strings", "[string/nstrcat.c]" ) TEST_CASE( "nstrcat: Error if first string is nil", "[string/nstrcat.c]" ) { error err; - string *s2 = nstr("", nil); - string *cat = nstrcat(nil, s2, &err); + nstr_t *s2 = nstr("", nil); + nstr_t *cat = nstrcat(nil, s2, &err); - string *expected_msg = nstr("First string is nil", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("First string is nil", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( cat == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -83,11 +83,11 @@ TEST_CASE( "nstrcat: Error if first string is nil", "[string/nstrcat.c]" ) TEST_CASE( "nstrcat: Error if second string is nil", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("", nil); - string *cat = nstrcat(s1, nil, &err); + nstr_t *s1 = nstr("", nil); + nstr_t *cat = nstrcat(s1, nil, &err); - string *expected_msg = nstr("Second string is nil", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Second string is nil", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( cat == nil ); REQUIRE( errnum(&err) == EFAULT ); diff --git a/test/string/nstrcmp.cpp b/test/string/nstrcmp.cpp index af85b14..6fe2d12 100644 --- a/test/string/nstrcmp.cpp +++ b/test/string/nstrcmp.cpp @@ -8,8 +8,8 @@ TEST_CASE( "nstrcmp: Return 0 if strings are equal", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("aaaaa", nil); - string *s2 = nstr("aaaaa", nil); + nstr_t *s1 = nstr("aaaaa", nil); + nstr_t *s2 = nstr("aaaaa", nil); int diff = nstrcmp(s1, s2, &err); @@ -23,8 +23,8 @@ TEST_CASE( "nstrcmp: Return 0 if strings are equal", "[string/nstrcat.c]" ) TEST_CASE( "nstrcmp: Return negative if first string is empty", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("", nil); - string *s2 = nstr("aaaaa", nil); + nstr_t *s1 = nstr("", nil); + nstr_t *s2 = nstr("aaaaa", nil); int diff = nstrcmp(s1, s2, &err); @@ -38,8 +38,8 @@ TEST_CASE( "nstrcmp: Return negative if first string is empty", "[string/nstrcat TEST_CASE( "nstrcmp: Return positive if second string is empty", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("aaaaa", nil); - string *s2 = nstr("", nil); + nstr_t *s1 = nstr("aaaaa", nil); + nstr_t *s2 = nstr("", nil); int diff = nstrcmp(s1, s2, &err); @@ -53,8 +53,8 @@ TEST_CASE( "nstrcmp: Return positive if second string is empty", "[string/nstrca TEST_CASE( "nstrcmp: Return 0 if both strings are empty", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("", nil); - string *s2 = nstr("", nil); + nstr_t *s1 = nstr("", nil); + nstr_t *s2 = nstr("", nil); int diff = nstrcmp(s1, s2, &err); @@ -69,8 +69,8 @@ TEST_CASE( "nstrcmp: Return positive if first string is larger", "[string/nstrca { error err; /* 'a' has a higher ASCII value than 'A' */ - string *s1 = nstr("aaaaa", nil); - string *s2 = nstr("aaaAa", nil); + nstr_t *s1 = nstr("aaaaa", nil); + nstr_t *s2 = nstr("aaaAa", nil); int diff = nstrcmp(s1, s2, &err); @@ -85,8 +85,8 @@ TEST_CASE( "nstrcmp: Return negative if second string is larger", "[string/nstrc { error err; /* 'a' has a higher ASCII value than 'A' */ - string *s1 = nstr("aaaAa", nil); - string *s2 = nstr("aaaaa", nil); + nstr_t *s1 = nstr("aaaAa", nil); + nstr_t *s2 = nstr("aaaaa", nil); int diff = nstrcmp(s1, s2, &err); @@ -101,11 +101,11 @@ TEST_CASE( "nstrcmp: Return negative if second string is larger", "[string/nstrc TEST_CASE( "nstrcmp: Error if first string is nil", "[string/nstrcat.c]" ) { error err; - string *s2 = nstr("aaaaa", nil); + nstr_t *s2 = nstr("aaaaa", nil); usize diff = nstrcmp(nil, s2, &err); - string *expected_msg = nstr("First string is nil", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("First string is nil", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( diff > 0 ); REQUIRE( errnum(&err) == EFAULT ); @@ -119,11 +119,11 @@ TEST_CASE( "nstrcmp: Error if first string is nil", "[string/nstrcat.c]" ) TEST_CASE( "nstrcmp: Error if second string is nil", "[string/nstrcat.c]" ) { error err; - string *s1 = nstr("aaaaa", nil); + nstr_t *s1 = nstr("aaaaa", nil); usize diff = nstrcmp(s1, nil, &err); - string *expected_msg = nstr("Second string is nil", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Second string is nil", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( diff > 0 ); REQUIRE( errnum(&err) == EFAULT ); diff --git a/test/string/nstrdup.cpp b/test/string/nstrdup.cpp index 023d965..c2dabff 100644 --- a/test/string/nstrdup.cpp +++ b/test/string/nstrdup.cpp @@ -8,8 +8,8 @@ TEST_CASE( "nstrdup: Duplicate a string", "[string/nstrcat.c]" ) { error err; - string *s = nstr("aaaaa", nil); - string *dup = nstrdup(s, &err); + nstr_t *s = nstr("aaaaa", nil); + nstr_t *dup = nstrdup(s, &err); REQUIRE( dup != nil ); REQUIRE( dup != s ); @@ -23,9 +23,9 @@ TEST_CASE( "nstrdup: Duplicate a string", "[string/nstrcat.c]" ) TEST_CASE( "nstrdup: Error if string is nil", "[string/nstrcat.c]" ) { error err; - string *dup = nstrdup(nil, &err); + nstr_t *dup = nstrdup(nil, &err); - string *expected_msg = nstr("String is nil", nil); + nstr_t *expected_msg = nstr("String is nil", nil); REQUIRE( dup == nil ); REQUIRE( errnum(&err) == EFAULT ); diff --git a/test/string/nstrmul.cpp b/test/string/nstrmul.cpp index 136f378..f9e0298 100644 --- a/test/string/nstrmul.cpp +++ b/test/string/nstrmul.cpp @@ -8,10 +8,10 @@ TEST_CASE( "nstrmul: Repeat a string", "[string/nstrcat.c]" ) { error err; - string *s = nstr("aaaaa", nil); + nstr_t *s = nstr("aaaaa", nil); - string *expected = nstr("aaaaaaaaaaaaaaa", nil); - string *actual = nstrmul(s, 3, &err); + nstr_t *expected = nstr("aaaaaaaaaaaaaaa", nil); + nstr_t *actual = nstrmul(s, 3, &err); REQUIRE( actual != nil ); REQUIRE( nlen(actual) == 5 * 3 ); @@ -26,9 +26,9 @@ TEST_CASE( "nstrmul: Repeat a string", "[string/nstrcat.c]" ) TEST_CASE( "nstrmul: Duplicate a string if count is 1", "[string/nstrcat.c]" ) { error err; - string *s = nstr("aaaaa", nil); + nstr_t *s = nstr("aaaaa", nil); - string *mul = nstrmul(s, 1, &err); + nstr_t *mul = nstrmul(s, 1, &err); REQUIRE( nul != nil ); REQUIRE( nlen(mul) == 5 ); @@ -42,9 +42,9 @@ TEST_CASE( "nstrmul: Duplicate a string if count is 1", "[string/nstrcat.c]" ) TEST_CASE( "nstrmul: Error if string is nil", "[string/nstrcat.c]" ) { error err; - string *mul = nstrmul(nil, 1, &err); + nstr_t *mul = nstrmul(nil, 1, &err); - string *expected_msg = nstr("String is nil", nil); + nstr_t *expected_msg = nstr("String is nil", nil); REQUIRE( mul == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -56,10 +56,10 @@ TEST_CASE( "nstrmul: Error if string is nil", "[string/nstrcat.c]" ) TEST_CASE( "nstrmul: Return empty string if count is 0", "[string/nstrcat.c]" ) { error err; - string *s = nstr("aaaaa", nil); - string *mul = nstrmul(s, 0, &err); + nstr_t *s = nstr("aaaaa", nil); + nstr_t *mul = nstrmul(s, 0, &err); - string *expected_msg = nstr("String is nil", nil); + nstr_t *expected_msg = nstr("String is nil", nil); REQUIRE( mul == nil ); REQUIRE( errnum(&err) == EFAULT ); @@ -71,9 +71,9 @@ TEST_CASE( "nstrmul: Return empty string if count is 0", "[string/nstrcat.c]" ) TEST_CASE( "nstrmul: Error if string is nil", "[string/nstrcat.c]" ) { error err; - string *mul = nstrmul(nil, 3, &err); + nstr_t *mul = nstrmul(nil, 3, &err); - string *expected_msg = nstr("String is nil", nil); + nstr_t *expected_msg = nstr("String is nil", nil); REQUIRE( mul == nil ); REQUIRE( errnum(&err) == EFAULT ); diff --git a/test/string/u2nstr.cpp b/test/string/u2nstr.cpp index 6708df2..b77351d 100644 --- a/test/string/u2nstr.cpp +++ b/test/string/u2nstr.cpp @@ -9,8 +9,8 @@ TEST_CASE( "u2nstr: Convert 0 to base 2", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("0", nil); - string *actual = u2nstr(0, 2, &err); + nstr_t *expected = nstr("0", nil); + nstr_t *actual = u2nstr(0, 2, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -24,8 +24,8 @@ TEST_CASE( "u2nstr: Convert 0 to base 36", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("0", nil); - string *actual = u2nstr(0, 36, &err); + nstr_t *expected = nstr("0", nil); + nstr_t *actual = u2nstr(0, 36, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -39,8 +39,8 @@ TEST_CASE( "u2nstr: Convert 255 to base 2", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("11111111", nil); - string *actual = u2nstr(255, 2, &err); + nstr_t *expected = nstr("11111111", nil); + nstr_t *actual = u2nstr(255, 2, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -54,8 +54,8 @@ TEST_CASE( "u2nstr: Convert 1679615 to base 36", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("zzzz", nil); - string *actual = u2nstr(1679615, 36, &err); + nstr_t *expected = nstr("zzzz", nil); + nstr_t *actual = u2nstr(1679615, 36, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -69,8 +69,8 @@ TEST_CASE( "u2nstr: Convert 2^64-1 to base 16", "[string/x2nstr.c]" ) { error err; - string *expected = nstr("ffffffffffffffff", nil); - string *actual = u2nstr(0xffffffffffffffff, 16, &err); + nstr_t *expected = nstr("ffffffffffffffff", nil); + nstr_t *actual = u2nstr(0xffffffffffffffff, 16, &err); REQUIRE( actual != nil ); REQUIRE( nstreq(expected, actual, nil) ); @@ -83,10 +83,10 @@ TEST_CASE( "u2nstr: Convert 2^64-1 to base 16", "[string/x2nstr.c]" ) TEST_CASE( "u2nstr: Error if base too low", "[string/x2nstr.c]" ) { error err; - string *s = u2nstr(420, 1, &err); + nstr_t *s = u2nstr(420, 1, &err); - string *expected_msg = nstr("Numerical base out of range", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Numerical base out of range", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( s == nil ); REQUIRE( nstreq(expected_msg, actual_msg, nil) ); @@ -99,10 +99,10 @@ TEST_CASE( "u2nstr: Error if base too low", "[string/x2nstr.c]" ) TEST_CASE( "u2nstr: Error if base too high", "[string/x2nstr.c]" ) { error err; - string *s = u2nstr(420, 37, &err); + nstr_t *s = u2nstr(420, 37, &err); - string *expected_msg = nstr("Numerical base out of range", nil); - string *actual_msg = errmsg(&err); + nstr_t *expected_msg = nstr("Numerical base out of range", nil); + nstr_t *actual_msg = errmsg(&err); REQUIRE( s == nil ); REQUIRE( nstreq(expected_msg, actual_msg, nil) ); diff --git a/test/string/utf/utf8_check.cpp b/test/string/utf/utf8_check.cpp index 8d6c110..d7248cc 100644 --- a/test/string/utf/utf8_check.cpp +++ b/test/string/utf/utf8_check.cpp @@ -50,8 +50,8 @@ TEST_CASE( "utf8_check: Error on malformed sequence start", "[string/utf.c]" ) error err; utf8_check("\xff", &err); - string *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -63,8 +63,8 @@ TEST_CASE( "utf8_check: Error on wrong second byte", "[string/utf.c]" ) error err; utf8_check("\xce\xff", &err); - string *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -76,8 +76,8 @@ TEST_CASE( "utf8_check: Error on wrong third byte", "[string/utf.c]" ) error err; utf8_check("\xe3\x81\xff", &err); - string *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -89,8 +89,8 @@ TEST_CASE( "utf8_check: Error on wrong fourth byte", "[string/utf.c]" ) error err; utf8_check("\xf0\x9f\xa5\xff", &err); - string *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -102,8 +102,8 @@ TEST_CASE( "utf8_check: Error on non canonical encoding", "[string/utf.c]" ) error err; utf8_check("\xf0\x80\x80\xa0", &err); - string *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); diff --git a/test/string/utf/utf8_chrsize.cpp b/test/string/utf/utf8_chrsize.cpp index 81e02d3..af82a6d 100644 --- a/test/string/utf/utf8_chrsize.cpp +++ b/test/string/utf/utf8_chrsize.cpp @@ -51,8 +51,8 @@ TEST_CASE( "utf8_chrsize: Error if out of Unicode range", "[string/utf.c]" ) /* Unicode range is 0x00~0x10ffff */ usize size = utf8_chrsize(0x110000, &err); - string *expected = nstr("Character code not within Unicode range", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Character code not within Unicode range", nil); + nstr_t *actual = errmsg(&err); REQUIRE( size == 0 ); REQUIRE( errnum(&err) == EINVAL ); diff --git a/test/string/utf/utf8_from_nchr.cpp b/test/string/utf/utf8_from_nchr.cpp index d0fef79..aa349c7 100644 --- a/test/string/utf/utf8_from_nchr.cpp +++ b/test/string/utf/utf8_from_nchr.cpp @@ -76,8 +76,8 @@ TEST_CASE( "utf8_from_nchr: Error if out of Unicode range", "[string/utf.c]" ) /* Unicode range is 0x00~0x10ffff */ usize size = utf8_from_nchr(&buf[0], 0x110000, &err); - string *expected = nstr("Character code not within Unicode range", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Character code not within Unicode range", nil); + nstr_t *actual = errmsg(&err); REQUIRE( buf[0] == '\0' ); REQUIRE( buf[1] == '\xff' ); diff --git a/test/string/utf/utf8_ncheck.cpp b/test/string/utf/utf8_ncheck.cpp index ba60b45..b6fc57e 100644 --- a/test/string/utf/utf8_ncheck.cpp +++ b/test/string/utf/utf8_ncheck.cpp @@ -64,8 +64,8 @@ TEST_CASE( "utf8_ncheck: Error on malformed sequence start", "[string/utf.c]" ) error err; utf8_ncheck("\xff", 1, &err); - string *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -77,8 +77,8 @@ TEST_CASE( "utf8_ncheck: Error on wrong second byte", "[string/utf.c]" ) error err; utf8_ncheck("\xce\xff", 2, &err); - string *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -90,8 +90,8 @@ TEST_CASE( "utf8_ncheck: Error on wrong third byte", "[string/utf.c]" ) error err; utf8_ncheck("\xe3\x81\xff", 3, &err); - string *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -103,8 +103,8 @@ TEST_CASE( "utf8_ncheck: Error on wrong fourth byte", "[string/utf.c]" ) error err; utf8_ncheck("\xf0\x9f\xa5\xff", 4, &err); - string *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); @@ -116,8 +116,8 @@ TEST_CASE( "utf8_ncheck: Error on non canonical encoding", "[string/utf.c]" ) error err; utf8_ncheck("\xf0\x80\x80\xa0", 4, &err); - string *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); + nstr_t *actual = errmsg(&err); REQUIRE( errnum(&err) == EINVAL ); REQUIRE( nstreq(expected, actual, nil) ); diff --git a/test/string/utf/utf8_to_nchr.cpp b/test/string/utf/utf8_to_nchr.cpp index 06f9b58..088ba2e 100644 --- a/test/string/utf/utf8_to_nchr.cpp +++ b/test/string/utf/utf8_to_nchr.cpp @@ -63,8 +63,8 @@ TEST_CASE( "utf8_to_nchr: Error on malformed sequence start", "[string/utf.c]" ) nchar c; utf8_to_nchr(&c, "\xff", &err); - string *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Illegal UTF-8 sequence start byte: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( c == '\0' ); REQUIRE( errnum(&err) == EINVAL ); @@ -78,8 +78,8 @@ TEST_CASE( "utf8_to_nchr: Error on wrong second byte", "[string/utf.c]" ) nchar c; utf8_to_nchr(&c, "\xce\xff", &err); - string *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 2 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( c == '\0' ); REQUIRE( errnum(&err) == EINVAL ); @@ -93,8 +93,8 @@ TEST_CASE( "utf8_to_nchr: Error on wrong third byte", "[string/utf.c]" ) nchar c; utf8_to_nchr(&c, "\xe3\x81\xff", &err); - string *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 3 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( c == '\0' ); REQUIRE( errnum(&err) == EINVAL ); @@ -108,8 +108,8 @@ TEST_CASE( "utf8_to_nchr: Error on wrong fourth byte", "[string/utf.c]" ) nchar c; utf8_to_nchr(&c, "\xf0\x9f\xa5\xff", &err); - string *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Byte 4 in UTF-8 sequence invalid: 0xff", nil); + nstr_t *actual = errmsg(&err); REQUIRE( c == '\0' ); REQUIRE( errnum(&err) == EINVAL ); @@ -123,8 +123,8 @@ TEST_CASE( "utf8_to_nchr: Error on non canonical encoding", "[string/utf.c]" ) nchar c; utf8_to_nchr(&c, "\xf0\x80\x80\xa0", &err); - string *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); - string *actual = errmsg(&err); + nstr_t *expected = nstr("Non canonical UTF-8 encoding: 1 byte character stored in 4 bytes", nil); + nstr_t *actual = errmsg(&err); REQUIRE( c == '\0' ); REQUIRE( errnum(&err) == EINVAL );