diff --git a/src/rtlib/strw_asc.c b/src/rtlib/strw_asc.c index 6024f1f3d3..7cb08b5a90 100644 --- a/src/rtlib/strw_asc.c +++ b/src/rtlib/strw_asc.c @@ -13,5 +13,14 @@ FBCALL unsigned int fb_WstrAsc( const FB_WCHAR *str, ssize_t pos ) if( (len == 0) || (pos <= 0) || (pos > len) ) return 0; else + /* on DOS, FB_WCHAR is a 'char' which is + typically signed. To avoid an undesired + sign extension for chars >= 128, cast + to unsigned char first + */ + #if defined HOST_DOS + return (unsigned char)str[pos-1]; + #else return str[pos-1]; + #endif } diff --git a/tests/fbc-tests.bas b/tests/fbc-tests.bas index 13907c62d4..7ea88134e4 100644 --- a/tests/fbc-tests.bas +++ b/tests/fbc-tests.bas @@ -11,6 +11,7 @@ dim opt_verbose as boolean = false dim opt_show_summary as boolean = true dim opt_xml_report as boolean = false dim opt_xml_filename as string = "" +dim opt_no_error as boolean = false dim i as integer = 1 @@ -23,6 +24,9 @@ while command(i) > "" case "-v", "--verbose" opt_verbose = true + case "--no-error" + opt_no_error = true + case "--xml" i += 1 opt_xml_report = true @@ -54,6 +58,7 @@ if( opt_help ) then print " -v, --verbose be verbose" print " --xml filename write test results to xml format for filename" print " --no-summary don't show the summary (default is to show it)" + print " --no-error don't exit with error code even if tests failed" print '' exit with an error code @@ -88,7 +93,8 @@ end if '' only return exit code = 0 if all tests passed and no other errors -if( passed ) then +'' or if the '-no-error' option was given, suspress the error code +if( passed or opt_no_error ) then end 0 end if diff --git a/tests/string/format.bas b/tests/string/format.bas index 40427552cc..71dca93426 100644 --- a/tests/string/format.bas +++ b/tests/string/format.bas @@ -3,12 +3,21 @@ '' tests marked with "BUG" might be bugged on some platforms #if ENABLE_CHECK_BUGS - #define BUG 1 + #define B1 1 + #define B2 1 #else + '' inhibit some checks on win 64bit (typically mingw64) #if defined(__FB_WIN32__) and defined(__FB_64BIT__) - #define BUG 0 + #define B1 0 #else - #define BUG 1 + #define B1 1 + #endif + '' inhibit some checks on mingw-org, however, we can't + '' tell the difference between mingw32 and mingw-org + #if defined(__FB_WIN32__) + #define B2 0 + #else + #define B2 1 #endif #endif @@ -46,12 +55,12 @@ tests_num: data 1, 0.1236, "#.##e-000", "1.24e-001" data 1, 0.000000000125, "#.##e-0", "1.25e-10" data 1, 0.999999, "#.00e+000", "1.00e+000" - data BUG, 9.9e+20, "#", "990000000000000000000" - data 1, 4.9e-324, "#.#e+#", "4.9e-324" - data BUG, 9.9e-100, "###################e+#", "9900000000000000000e-118" + data B1, 9.9e+20, "#", "990000000000000000000" + data B2, 4.9e-324, "#.#e+#", "4.9e-324" + data B1, 9.9e-100, "###################e+#", "9900000000000000000e-118" data 1, -0.1236, "##0.00%", "-12.36%" - data 1, -123, !"\"asd\\\"", !"asd\\" + data 1, -123, !"\"asd\\\"", !"asd\\" data 1, -0, "###", "0" data 1, -123, "###", "-123" data 1, -123, "###00000", "-00123" @@ -76,9 +85,9 @@ tests_num: data 1, -0.1236, "#.##e-000", "-1.24e-001" data 1, -0.000000000125, "#.##e-0", "-1.25e-10" data 1, -0.999999, "#.00e+000", "-1.00e+000" - data BUG, -9.9e+20, "#", "-990000000000000000000" - data 1, -4.9e-324, "#.#e+#", "-4.9e-324" - data BUG, -9.9e-100, "###################e+#", "-9900000000000000000e-118" + data B1, -9.9e+20, "#", "-990000000000000000000" + data B2, -4.9e-324, "#.#e+#", "-4.9e-324" + data B1, -9.9e-100, "###################e+#", "-9900000000000000000e-118" data 1, -0.1236, "##0.00%-", "12.36%-" data 1, -123, !"\"asd\\\"", !"asd\\" @@ -106,12 +115,12 @@ tests_num: data 1, -0.1236, "#.##e-000-", "1.24e-001-" data 1, -0.000000000125, "#.##e-0-", "1.25e-10-" data 1, -0.999999, "#.00e+000-", "1.00e+000-" - data BUG, -9.9e+20, "#-", "990000000000000000000-" - data 1, -4.9e-324, "#.#e+#-", "4.9e-324-" - data BUG, -9.9e-100, "###################e+#-", "9900000000000000000e-118-" + data B1, -9.9e+20, "#-", "990000000000000000000-" + data B2, -4.9e-324, "#.#e+#-", "4.9e-324-" + data B1, -9.9e-100, "###################e+#-", "9900000000000000000e-118-" data 1, 0.1236, "##0.00%-", "12.36%" - data 1, 123, !"\"asd\\\"", !"asd\\" + data 1, 123, !"\"asd\\\"", !"asd\\" data 1, 0, "###-", "0" data 1, 123, "###-", "123" data 1, 123, "###00000-", "00123" @@ -136,9 +145,9 @@ tests_num: data 1, 0.1236, "#.##e-000-", "1.24e-001" data 1, 0.000000000125, "#.##e-0-", "1.25e-10" data 1, 0.999999, "#.00e+000-", "1.00e+000" - data BUG, 9.9e+20, "#-", "990000000000000000000" - data 1, 4.9e-324, "#.#e+#-", "4.9e-324" - data BUG, 9.9e-100, "###################e+#-", "9900000000000000000e-118" + data B1, 9.9e+20, "#-", "990000000000000000000" + data B2, 4.9e-324, "#.#e+#-", "4.9e-324" + data B1, 9.9e-100, "###################e+#-", "9900000000000000000e-118" data 1, 1234, "###,0.00", "1,234.00" data 1, 1234567, "#,#,#,0.00", "1,234,567.00" @@ -152,7 +161,7 @@ tests_num: data 1, 123, "#########,0.00", "123.00" data 1, 100000, "#,##0.00", "100,000.00" - data 1, "." + data 1, "." tests_dt: data "Jun 1, 2005", "yyyy-mm-dd", "2005-06-01" diff --git a/tests/udt-zstring/asc.bas b/tests/udt-zstring/asc.bas index bc41fea0bb..5e5fa8f1f3 100644 --- a/tests/udt-zstring/asc.bas +++ b/tests/udt-zstring/asc.bas @@ -26,6 +26,9 @@ SUITE( fbc_tests.udt_zstring_.asc_ ) END_TEST +'' only test where sizeof(wstring) >= 2, because +'' it won't be on DOS where sizeof(wstring) = 1. +#if sizeof(WSTRING) >= 2 TEST( ucs2 ) dim s as zstring * 256 for i as uinteger = 1 to 255 @@ -45,5 +48,6 @@ SUITE( fbc_tests.udt_zstring_.asc_ ) next END_TEST +#endif END_SUITE diff --git a/tests/wstring/asc.bas b/tests/wstring/asc.bas index 14b8557954..ce73152e15 100644 --- a/tests/wstring/asc.bas +++ b/tests/wstring/asc.bas @@ -37,6 +37,9 @@ SUITE( fbc_tests.wstring_.asc_ ) next END_TEST +'' only test where sizeof(wstring) >= 2, because +'' it won't be on DOS where sizeof(wstring) = 1. +#if sizeof(WSTRING) >= 2 TEST( ucs2 ) dim w as wstring * 256 for i as integer = 1 to 255 @@ -54,5 +57,6 @@ SUITE( fbc_tests.wstring_.asc_ ) end select next END_TEST +#endif END_SUITE