Skip to content

Commit da305e5

Browse files
committed
udt-wstring: LCASE, UCASE, will accept UDT as z|wstring
1 parent f02b30d commit da305e5

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Version 1.07.0
1010
- github #141: makefile option 'ENABLE_STRIPALL=1' introduced to pass '-d ENABLE_STRIPALL' via FBCFLAGS by default for dos/win32 targets (William Breathitt Gray)
1111
- 'TYPE udt EXTENDS Z|WSTRING' allowed to specify that UDT is a kind of Z|WSTRING
1212
- LTRIM/RTRIM/TRIM will accept UDT as Z|WSTRING
13+
- LCASE/UCASE will accept UDT as Z|WSTRING
1314

1415
[fixed]
1516
- sf.net #881: C backend: support for varadic function parameters in gcc using __builtin_va_list type and related macros

src/compiler/rtl-string.bas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3791,6 +3791,8 @@ function rtlStrCase _
37913791
end if
37923792
end if
37933793

3794+
astTryConvertUdtToWstring( expr )
3795+
37943796
if( is_lcase ) then
37953797
if( astGetDataType( expr ) = FB_DATATYPE_WCHAR ) then
37963798
f = PROCLOOKUP( WSTRLCASE2 )

tests/udt-wstring/case.bas

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "fbcunit.bi"
2+
#include once "uwstring-fixed.bi"
3+
#include once "chk-wstring.bi"
4+
5+
#define ustring UWSTRING_FIXED
6+
7+
SUITE( fbc_tests.udt_wstring_.case_ )
8+
9+
'' U/LCASE( wstring )
10+
#macro check_rtlfunc( rtlfunc, text )
11+
scope
12+
dim t as wstring * 50 = text
13+
dim u as ustring = t
14+
15+
CU_ASSERT( t = text )
16+
CU_ASSERT( u = t )
17+
18+
dim rt as wstring * 50 = rtlfunc( t )
19+
dim ru as wstring * 50 = rtlfunc( u )
20+
CU_ASSERT_WSTRING_EQUAL( rt, ru )
21+
22+
end scope
23+
#endmacro
24+
25+
#macro check( text )
26+
check_rtlfunc( ucase, text )
27+
check_rtlfunc( lcase, text )
28+
#endmacro
29+
30+
TEST( default )
31+
check( "" )
32+
check( " " )
33+
check( " " )
34+
check( "abcde" )
35+
check( "asdfghjkl" )
36+
check( !"\u30a1\u30a3\u30a5\u30a7\u30a9" ) '' katakana
37+
check( !"\u0444\u044b\u0432\u0430\u043f\u0440" ) '' russian
38+
check( !"asd wstring fghjkl\u4644" )
39+
check( "QWERTZUIOP" )
40+
check( "1234567890" )
41+
END_TEST
42+
43+
END_SUITE

tests/udt-zstring/case.bas

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "fbcunit.bi"
2+
#include once "uzstring-fixed.bi"
3+
#include once "chk-zstring.bi"
4+
5+
#define ustring UZSTRING_FIXED
6+
7+
SUITE( fbc_tests.udt_zstring_.case_ )
8+
9+
'' U/LCASE( zstring )
10+
#macro check_rtlfunc( rtlfunc, text )
11+
scope
12+
dim t as zstring * 50 = text
13+
dim u as ustring = t
14+
15+
CU_ASSERT( t = text )
16+
CU_ASSERT( u = t )
17+
18+
dim rt as zstring * 50 = rtlfunc( t )
19+
dim ru as zstring * 50 = rtlfunc( u )
20+
CU_ASSERT_ZSTRING_EQUAL( rt, ru )
21+
end scope
22+
#endmacro
23+
24+
#macro check( text )
25+
check_rtlfunc( ucase, text )
26+
check_rtlfunc( lcase, text )
27+
#endmacro
28+
29+
TEST( default )
30+
check( "" )
31+
check( " " )
32+
check( " " )
33+
check( "abcde" )
34+
check( "asdfghjkl" )
35+
check( "QWERTZUIOP" )
36+
check( "1234567890" )
37+
END_TEST
38+
39+
END_SUITE

0 commit comments

Comments
 (0)