From bb6e2d6885283291e04604b6daf8bd85d9c23eea Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 4 Jul 2024 06:38:09 +0300 Subject: [PATCH] public: add Q_colorstr and Q_strnlwr tests --- public/tests/test_strings.c | 49 +++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/public/tests/test_strings.c b/public/tests/test_strings.c index e9f63d17..9701fc30 100644 --- a/public/tests/test_strings.c +++ b/public/tests/test_strings.c @@ -1,7 +1,6 @@ -#include #include "crtlib.h" -int Test_Strcpycatcmp( void ) +static int Test_Strcpycatcmp( void ) { char buf[] = "meowmeowmeow", buf2[] = "barkbark"; char dst[64]; @@ -30,10 +29,50 @@ int Test_Strcpycatcmp( void ) return 0; } +static int Test_Strnlwr( void ) +{ + string s; + + Q_strnlwr( "ASDFGKJ", s, sizeof( s )); + + if( Q_strcmp( s, "asdfgkj" )) + return 1; + + Q_strnlwr( "qwertyuiop", s, sizeof( s )); + + if( Q_strcmp( s, "qwertyuiop" )) + return 2; + + return 0; +} + +static int Test_Colorstr( void ) +{ + if( Q_colorstr( "^1color^2string" ) != 4 ) + return 1; + + if( Q_colorstr( "colorlessstring" ) != 0 ) + return 2; + + return 0; +} + int main( void ) { - if( Test_Strcpycatcmp( )) - return EXIT_FAILURE; + int ret = Test_Strcpycatcmp(); - return EXIT_SUCCESS; + if( ret > 0 ) + return ret; + + ret = Test_Strnlwr(); + + if( ret > 0 ) + return ret + 16; + + ret = Test_Colorstr(); + + if( ret > 0 ) + return ret + 32; + + return 0; }