Skip to content

Commit 53e9f54

Browse files
authored
Merge pull request #168 from jayrm/fbc-tests
fbc-tests: wstring and DOS compatibility
2 parents 4a0f4d2 + e17a1f7 commit 53e9f54

File tree

5 files changed

+51
-19
lines changed

5 files changed

+51
-19
lines changed

src/rtlib/strw_asc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@ FBCALL unsigned int fb_WstrAsc( const FB_WCHAR *str, ssize_t pos )
1313
if( (len == 0) || (pos <= 0) || (pos > len) )
1414
return 0;
1515
else
16+
/* on DOS, FB_WCHAR is a 'char' which is
17+
typically signed. To avoid an undesired
18+
sign extension for chars >= 128, cast
19+
to unsigned char first
20+
*/
21+
#if defined HOST_DOS
22+
return (unsigned char)str[pos-1];
23+
#else
1624
return str[pos-1];
25+
#endif
1726
}

tests/fbc-tests.bas

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dim opt_verbose as boolean = false
1111
dim opt_show_summary as boolean = true
1212
dim opt_xml_report as boolean = false
1313
dim opt_xml_filename as string = ""
14+
dim opt_no_error as boolean = false
1415

1516
dim i as integer = 1
1617

@@ -23,6 +24,9 @@ while command(i) > ""
2324
case "-v", "--verbose"
2425
opt_verbose = true
2526

27+
case "--no-error"
28+
opt_no_error = true
29+
2630
case "--xml"
2731
i += 1
2832
opt_xml_report = true
@@ -54,6 +58,7 @@ if( opt_help ) then
5458
print " -v, --verbose be verbose"
5559
print " --xml filename write test results to xml format for filename"
5660
print " --no-summary don't show the summary (default is to show it)"
61+
print " --no-error don't exit with error code even if tests failed"
5762
print
5863

5964
'' exit with an error code
@@ -88,7 +93,8 @@ end if
8893

8994

9095
'' only return exit code = 0 if all tests passed and no other errors
91-
if( passed ) then
96+
'' or if the '-no-error' option was given, suspress the error code
97+
if( passed or opt_no_error ) then
9298
end 0
9399
end if
94100

tests/string/format.bas

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@
33

44
'' tests marked with "BUG" might be bugged on some platforms
55
#if ENABLE_CHECK_BUGS
6-
#define BUG 1
6+
#define B1 1
7+
#define B2 1
78
#else
9+
'' inhibit some checks on win 64bit (typically mingw64)
810
#if defined(__FB_WIN32__) and defined(__FB_64BIT__)
9-
#define BUG 0
11+
#define B1 0
1012
#else
11-
#define BUG 1
13+
#define B1 1
14+
#endif
15+
'' inhibit some checks on mingw-org, however, we can't
16+
'' tell the difference between mingw32 and mingw-org
17+
#if defined(__FB_WIN32__)
18+
#define B2 0
19+
#else
20+
#define B2 1
1221
#endif
1322
#endif
1423

@@ -46,12 +55,12 @@ tests_num:
4655
data 1, 0.1236, "#.##e-000", "1.24e-001"
4756
data 1, 0.000000000125, "#.##e-0", "1.25e-10"
4857
data 1, 0.999999, "#.00e+000", "1.00e+000"
49-
data BUG, 9.9e+20, "#", "990000000000000000000"
50-
data 1, 4.9e-324, "#.#e+#", "4.9e-324"
51-
data BUG, 9.9e-100, "###################e+#", "9900000000000000000e-118"
58+
data B1, 9.9e+20, "#", "990000000000000000000"
59+
data B2, 4.9e-324, "#.#e+#", "4.9e-324"
60+
data B1, 9.9e-100, "###################e+#", "9900000000000000000e-118"
5261

5362
data 1, -0.1236, "##0.00%", "-12.36%"
54-
data 1, -123, !"\"asd\\\"", !"asd\\"
63+
data 1, -123, !"\"asd\\\"", !"asd\\"
5564
data 1, -0, "###", "0"
5665
data 1, -123, "###", "-123"
5766
data 1, -123, "###00000", "-00123"
@@ -76,9 +85,9 @@ tests_num:
7685
data 1, -0.1236, "#.##e-000", "-1.24e-001"
7786
data 1, -0.000000000125, "#.##e-0", "-1.25e-10"
7887
data 1, -0.999999, "#.00e+000", "-1.00e+000"
79-
data BUG, -9.9e+20, "#", "-990000000000000000000"
80-
data 1, -4.9e-324, "#.#e+#", "-4.9e-324"
81-
data BUG, -9.9e-100, "###################e+#", "-9900000000000000000e-118"
88+
data B1, -9.9e+20, "#", "-990000000000000000000"
89+
data B2, -4.9e-324, "#.#e+#", "-4.9e-324"
90+
data B1, -9.9e-100, "###################e+#", "-9900000000000000000e-118"
8291

8392
data 1, -0.1236, "##0.00%-", "12.36%-"
8493
data 1, -123, !"\"asd\\\"", !"asd\\"
@@ -106,12 +115,12 @@ tests_num:
106115
data 1, -0.1236, "#.##e-000-", "1.24e-001-"
107116
data 1, -0.000000000125, "#.##e-0-", "1.25e-10-"
108117
data 1, -0.999999, "#.00e+000-", "1.00e+000-"
109-
data BUG, -9.9e+20, "#-", "990000000000000000000-"
110-
data 1, -4.9e-324, "#.#e+#-", "4.9e-324-"
111-
data BUG, -9.9e-100, "###################e+#-", "9900000000000000000e-118-"
118+
data B1, -9.9e+20, "#-", "990000000000000000000-"
119+
data B2, -4.9e-324, "#.#e+#-", "4.9e-324-"
120+
data B1, -9.9e-100, "###################e+#-", "9900000000000000000e-118-"
112121

113122
data 1, 0.1236, "##0.00%-", "12.36%"
114-
data 1, 123, !"\"asd\\\"", !"asd\\"
123+
data 1, 123, !"\"asd\\\"", !"asd\\"
115124
data 1, 0, "###-", "0"
116125
data 1, 123, "###-", "123"
117126
data 1, 123, "###00000-", "00123"
@@ -136,9 +145,9 @@ tests_num:
136145
data 1, 0.1236, "#.##e-000-", "1.24e-001"
137146
data 1, 0.000000000125, "#.##e-0-", "1.25e-10"
138147
data 1, 0.999999, "#.00e+000-", "1.00e+000"
139-
data BUG, 9.9e+20, "#-", "990000000000000000000"
140-
data 1, 4.9e-324, "#.#e+#-", "4.9e-324"
141-
data BUG, 9.9e-100, "###################e+#-", "9900000000000000000e-118"
148+
data B1, 9.9e+20, "#-", "990000000000000000000"
149+
data B2, 4.9e-324, "#.#e+#-", "4.9e-324"
150+
data B1, 9.9e-100, "###################e+#-", "9900000000000000000e-118"
142151

143152
data 1, 1234, "###,0.00", "1,234.00"
144153
data 1, 1234567, "#,#,#,0.00", "1,234,567.00"
@@ -152,7 +161,7 @@ tests_num:
152161
data 1, 123, "#########,0.00", "123.00"
153162
data 1, 100000, "#,##0.00", "100,000.00"
154163

155-
data 1, "."
164+
data 1, "."
156165

157166
tests_dt:
158167
data "Jun 1, 2005", "yyyy-mm-dd", "2005-06-01"

tests/udt-zstring/asc.bas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ SUITE( fbc_tests.udt_zstring_.asc_ )
2626

2727
END_TEST
2828

29+
'' only test where sizeof(wstring) >= 2, because
30+
'' it won't be on DOS where sizeof(wstring) = 1.
31+
#if sizeof(WSTRING) >= 2
2932
TEST( ucs2 )
3033
dim s as zstring * 256
3134
for i as uinteger = 1 to 255
@@ -45,5 +48,6 @@ SUITE( fbc_tests.udt_zstring_.asc_ )
4548
next
4649

4750
END_TEST
51+
#endif
4852

4953
END_SUITE

tests/wstring/asc.bas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ SUITE( fbc_tests.wstring_.asc_ )
3737
next
3838
END_TEST
3939

40+
'' only test where sizeof(wstring) >= 2, because
41+
'' it won't be on DOS where sizeof(wstring) = 1.
42+
#if sizeof(WSTRING) >= 2
4043
TEST( ucs2 )
4144
dim w as wstring * 256
4245
for i as integer = 1 to 255
@@ -54,5 +57,6 @@ SUITE( fbc_tests.wstring_.asc_ )
5457
end select
5558
next
5659
END_TEST
60+
#endif
5761

5862
END_SUITE

0 commit comments

Comments
 (0)