Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/rtlib/strw_asc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion tests/fbc-tests.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
45 changes: 27 additions & 18 deletions tests/string/format.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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\\"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tests/udt-zstring/asc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,5 +48,6 @@ SUITE( fbc_tests.udt_zstring_.asc_ )
next

END_TEST
#endif

END_SUITE
4 changes: 4 additions & 0 deletions tests/wstring/asc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,5 +57,6 @@ SUITE( fbc_tests.wstring_.asc_ )
end select
next
END_TEST
#endif

END_SUITE