string: rename string type to nstr_t

This might annoy a bunch of people, but it kinda
follows the "traditional" C coding style and i
like it more.  Also it reminds you that strings
are absolutely not a primitive data type.
This commit is contained in:
anna 2021-07-22 12:20:53 +02:00
parent cb09acbc7c
commit c797540dbc
Signed by: fef
GPG key ID: EC22E476DC2D3D84
27 changed files with 208 additions and 208 deletions

View file

@ -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) );