297 a.Justify(b,10,ELeft,' '); |
298 a.Justify(b,10,ELeft,' '); |
298 b.Fill('A',2); |
299 b.Fill('A',2); |
299 a.Zero(); |
300 a.Zero(); |
300 a.AppendJustify(_TL("AB"),10,ELeft,' '); |
301 a.AppendJustify(_TL("AB"),10,ELeft,' '); |
301 a.AppendJustify(b,10,ELeft,' '); |
302 a.AppendJustify(b,10,ELeft,' '); |
|
303 a.AppendJustify(b,10,KDefaultJustifyWidth,ELeft,' '); |
|
304 a.AppendJustify(b.Ptr(),10,ELeft,' '); |
|
305 |
302 TInt v1=10; |
306 TInt v1=10; |
303 a.Num(v1); |
307 a.Num(v1); |
304 a.AppendNum(v1); |
308 a.AppendNum(v1); |
305 TInt v2=10; |
309 TInt v2=10; |
306 a.Num((TUint)v2,EHex); |
310 a.Num((TUint)v2,EHex); |
307 a.AppendNum((TUint)v2,EHex); |
311 a.AppendNum((TUint)v2,EHex); |
308 a.NumUC((TUint)v2,EHex); |
312 a.NumUC((TUint)v2,EHex); |
309 a.AppendNumUC((TUint)v2,EHex); |
313 a.AppendNumUC((TUint)v2,EHex); |
|
314 |
|
315 //Converts the specified unsigned integer into a fixed width character representation |
|
316 //based on the specified number system and copies the conversion into this descriptor, |
|
317 //replacing any existing data. The length of this descriptor is set to reflect the new data. |
|
318 a.NumFixedWidth(v1,EBinary,4); |
|
319 a.NumFixedWidth(v1,EOctal,3); |
|
320 a.NumFixedWidth(v1,EDecimal,2); |
|
321 a.NumFixedWidth(v1,EHex,1); |
|
322 //When a hexadecimal conversion is specified, hexadecimal characters are in upper case. |
|
323 a.NumFixedWidthUC(v1,EBinary,4); |
|
324 a.NumFixedWidthUC(v1,EOctal,3); |
|
325 a.NumFixedWidthUC(v1,EDecimal,2); |
|
326 a.NumFixedWidthUC(v1,EHex,1); |
|
327 //Appends the conversion onto the end of this descriptor's data. |
|
328 a.AppendNumFixedWidthUC(v1,EBinary,4); |
|
329 a.AppendNumFixedWidthUC(v1,EOctal,3); |
|
330 a.AppendNumFixedWidthUC(v1,EDecimal,2); |
|
331 a.AppendNumFixedWidthUC(v1,EHex,1); |
|
332 |
310 TReal v3=10.0; |
333 TReal v3=10.0; |
311 TRealFormat ff; |
334 TRealFormat ff; |
312 ff.iType=KRealFormatFixed; |
335 ff.iType=KRealFormatFixed; |
313 ff.iWidth=10; |
336 ff.iWidth=10; |
314 ff.iPlaces=2; |
337 ff.iPlaces=2; |
1357 |
1380 |
1358 // Cannot do this on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime". |
1381 // Cannot do this on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime". |
1359 #if !(defined(__GCC32__) && defined(__X86__)) |
1382 #if !(defined(__GCC32__) && defined(__X86__)) |
1360 const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E"); |
1383 const TAny* const zeroTerminatedString=(sizeof(S)==2)? (const TAny*)_S16(":-)E"): (const TAny*)_S8(":-)E"); |
1361 const TInt dummyParameter=0; |
1384 const TInt dummyParameter=0; |
|
1385 #ifdef __ARMCC__ |
|
1386 #pragma push |
|
1387 #pragma diag_suppress 1446 |
|
1388 #endif |
1362 Test14_ReorderedParameterFormatting(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd); |
1389 Test14_ReorderedParameterFormatting(dummyParameter, 0x20ac, 11, 3, 13.89543, zeroTerminatedString, '!', TInt64(199), 2, &b, 6, 30005, TRealX(0.125), 0x8bdd); |
|
1390 #ifdef __ARMCC__ |
|
1391 #pragma pop |
|
1392 #endif |
1363 #endif |
1393 #endif |
1364 |
1394 |
1365 test.Next(_L("Print some numbers")); |
1395 test.Next(_L("Print some numbers")); |
1366 TInt64 TI64 = MAKE_TINT64(0x101010u,0x10101010u); |
1396 TInt64 TI64 = MAKE_TINT64(0x101010u,0x10101010u); |
1367 test.Printf(_L(" %%ld: %ld\n"),TI64); |
1397 test.Printf(_L(" %%ld: %ld\n"),TI64); |
1566 aa.Format(_L("x%5.1fx"), 1.99); |
1596 aa.Format(_L("x%5.1fx"), 1.99); |
1567 test(aa==_L("x 2.0x")); |
1597 test(aa==_L("x 2.0x")); |
1568 |
1598 |
1569 // Cannot do these on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime". |
1599 // Cannot do these on GCC (X86) because of "Cannot pass objects of non-POD type through '...'. Call will abort at runtime". |
1570 #if !(defined(__GCC32__) && defined(__X86__)) |
1600 #if !(defined(__GCC32__) && defined(__X86__)) |
|
1601 #ifdef __ARMCC__ |
|
1602 #pragma push |
|
1603 #pragma diag_suppress 1446 |
|
1604 #endif |
1571 aa.Format(_L("x%- 5Fx"), TRealX(6.2345678)); |
1605 aa.Format(_L("x%- 5Fx"), TRealX(6.2345678)); |
1572 test(aa==_L("x6.234568x")); |
1606 test(aa==_L("x6.234568x")); |
1573 aa.Format(_L("x%+ 5Fx"), TRealX(6.2345678)); |
1607 aa.Format(_L("x%+ 5Fx"), TRealX(6.2345678)); |
1574 test(aa==_L("x6.234568x")); |
1608 test(aa==_L("x6.234568x")); |
1575 aa.Format(_L("x% 5Fx"), TRealX(6.2345678)); |
1609 aa.Format(_L("x% 5Fx"), TRealX(6.2345678)); |
1596 test(aa==_L("x12,345,352,342.545000x")); |
1630 test(aa==_L("x12,345,352,342.545000x")); |
1597 aa.Format(_L("x%20.9Fx"), TRealX(1.0123456789)); |
1631 aa.Format(_L("x%20.9Fx"), TRealX(1.0123456789)); |
1598 test(aa==_L("x 1.012345679x")); |
1632 test(aa==_L("x 1.012345679x")); |
1599 aa.Format(_L("x%5.1Fx"), TRealX(1.99)); |
1633 aa.Format(_L("x%5.1Fx"), TRealX(1.99)); |
1600 test(aa==_L("x 2.0x")); |
1634 test(aa==_L("x 2.0x")); |
|
1635 #ifdef __ARMCC__ |
|
1636 #pragma pop |
|
1637 #endif |
1601 #endif |
1638 #endif |
1602 |
1639 |
1603 aa.Format(_L("x%- 5ex"), 6.2345678); |
1640 aa.Format(_L("x%- 5ex"), 6.2345678); |
1604 test(aa==_L("x6.234568E+00x")); |
1641 test(aa==_L("x6.234568E+00x")); |
1605 aa.Format(_L("x%+ 5ex"), 6.2345678); |
1642 aa.Format(_L("x%+ 5ex"), 6.2345678); |
1879 test(err == KErrNone); |
1916 test(err == KErrNone); |
1880 |
1917 |
1881 lang = User::Language(); |
1918 lang = User::Language(); |
1882 test(lang == defaultLang); |
1919 test(lang == defaultLang); |
1883 } |
1920 } |
|
1921 |
|
1922 // Test the surrogate aware version functions of the class. |
|
1923 GLDEF_C void SurrogateAware1() |
|
1924 { |
|
1925 test.Start(_L("Constructors")); |
|
1926 TBuf16<0x50> a; |
|
1927 TBuf16<0x50> b; |
|
1928 TBuf16<0x50> c; |
|
1929 TBuf16<0x50> d; |
|
1930 |
|
1931 a=_L("ABCD"); |
|
1932 b=_L("abcd"); |
|
1933 // Cannot define these on GCC (X86). |
|
1934 #if !(defined(__GCC32__) && defined(__X86__)) |
|
1935 c=_L("àáâãäåçèéêëìíîïñòóôõöùúûüý"); |
|
1936 d=_L("ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ"); |
|
1937 #else |
|
1938 c=_L("aaaaaaceeeeiiiinooooouuuuy"); |
|
1939 d=_L("AAAAAACEEEEIIIINOOOOOUUUUY"); |
|
1940 #endif |
|
1941 |
|
1942 test.Next(_L("Fill2")); |
|
1943 TInt maxBufLength=a.MaxLength(); |
|
1944 a.Fill2(' '); |
|
1945 a.Fill2(' ',maxBufLength); |
|
1946 a.Fill2('z'); |
|
1947 a.Fill2('*',maxBufLength); |
|
1948 a=c; |
|
1949 b=d; |
|
1950 a.Swap(b); |
|
1951 test(a==d); |
|
1952 |
|
1953 test.Next(_L("Conversion 2")); |
|
1954 a.Fold2(); |
|
1955 b.Collate2(); |
|
1956 a.UpperCase2(); |
|
1957 a.LowerCase2(); |
|
1958 a.Capitalize2(); |
|
1959 b.Capitalize2(); |
|
1960 |
|
1961 test.Next(_L("Locating")); |
|
1962 a=_L("ABCDabcd"); |
|
1963 test(a.Locate('A')==0); |
|
1964 test(a.LocateF('b')==1); |
|
1965 test(a.LocateReverse('A')==0); |
|
1966 test(a.LocateReverse('a')==4); |
|
1967 test(a.LocateReverse('b')==5); |
|
1968 |
|
1969 test.Next(_L("Copying")); |
|
1970 a.Copy(b); // Copies a 16 bit descriptor |
|
1971 a.Copy(_L("AB")); |
|
1972 a.Copy(b.Ptr(),3); // Copies aLength characters from the aBuf pointer |
|
1973 a.CopyF2(c); // Copies and folds |
|
1974 a.CopyF2(_L("AB")); |
|
1975 a.CopyC2(d); // Copies and collates |
|
1976 a.CopyC2(_L("AB")); |
|
1977 a.CopyLC(d); // Copies and converts the text to lower case |
|
1978 a.CopyLC(_L("AB")); |
|
1979 a.CopyUC2(c); // Copies and converts the text to upper case |
|
1980 a.CopyUC2(_L("AB")); |
|
1981 a.CopyCP2(b); // Copies and capitalizes the text |
|
1982 a.CopyCP2(_L("AB")); |
|
1983 |
|
1984 test.Next(_L("Finding")); |
|
1985 a=_L("ABCDabcd"); |
|
1986 b=_L("bc"); |
|
1987 test(a.Find(b)==5); |
|
1988 test(a.Find(_L("ab"))==4); |
|
1989 test(a.FindF(b)==1); |
|
1990 test(a.FindF(_L("ab"))==0); |
|
1991 test(a.FindC(b)==1); |
|
1992 test(a.FindC(_L("AB"))==0); |
|
1993 test(a.FindC(b.Ptr(), b.Length(), 3)==1); |
|
1994 test(a.FindC(b.Ptr(), b.Length(), 2)==1); |
|
1995 test(a.FindC(b.Ptr(), b.Length(), 1)==1); |
|
1996 test(a.FindC(b.Ptr(), b.Length(), 0)==1); |
|
1997 test(a.FindF(b.Ptr(), b.Length())==1); |
|
1998 |
|
1999 test.Next(_L("Formating")); |
|
2000 TInt width = 10; |
|
2001 a.Justify2(_L("AB"),width,ELeft,' '); |
|
2002 a.Justify2(b,10,ELeft,' '); |
|
2003 b.Fill2('A',2); |
|
2004 a.Zero(); |
|
2005 a.AppendJustify2(_L("AB"),width,ELeft,' '); |
|
2006 a.AppendJustify2(b,width,ELeft,' '); |
|
2007 a=_L("ABCDE"); |
|
2008 b=_L("abcde"); |
|
2009 a.AppendJustify2(b,width,ELeft,'*'); |
|
2010 a.AppendJustify2(b.Ptr(),width,ELeft,'*'); |
|
2011 // Append and justify with explicit length |
|
2012 TInt length = 5; |
|
2013 a.AppendJustify2(b,length,KDefaultJustifyWidth,ELeft,'*'); |
|
2014 a.AppendJustify2(b.Ptr(),length,KDefaultJustifyWidth,ELeft,'*'); |
|
2015 |
|
2016 TCollationMethod cm = *Mem::CollationMethodByIndex( 0 ); // default collation method |
|
2017 cm.iFlags |= TCollationMethod::EIgnoreNone; |
|
2018 TDesC::TPrefix prefix = a.HasPrefixC(a, 0, &cm); |
|
2019 test(prefix==TDesC16::EIsPrefix); |
|
2020 test.End(); |
|
2021 } |
|
2022 |
|
2023 // Test the surrogate aware versions of conversion operators (test7) |
|
2024 // |
|
2025 void SurrogateAware7() |
|
2026 { |
|
2027 test.Start(_L("Fold2, Collate2 ...")); |
|
2028 TBuf16<0x50> a; |
|
2029 TBuf16<0x50> b; |
|
2030 a=_L("abc AbC"); |
|
2031 b=_L("ABC ABC"); |
|
2032 a.Fold2(); |
|
2033 b.Fold2(); |
|
2034 test(a==b); |
|
2035 a=_L("abc AbC"); |
|
2036 b=_L("ABC ABC"); |
|
2037 a.Collate2(); |
|
2038 b.Collate2(); |
|
2039 test(a==b); |
|
2040 a.UpperCase2(); |
|
2041 test(a==_L("ABC ABC")); |
|
2042 a.LowerCase2(); |
|
2043 test(a==_L("abc abc")); |
|
2044 a.Capitalize2(); |
|
2045 test(a==_L("Abc abc")); |
|
2046 test.End(); |
|
2047 } |
|
2048 |
1884 #ifndef _DEBUG |
2049 #ifndef _DEBUG |
1885 #pragma warning( disable : 4702) //Unreachable code |
2050 #pragma warning( disable : 4702) //Unreachable code |
1886 #pragma warning( disable : 4710) //Function not expanded |
2051 #pragma warning( disable : 4710) //Function not expanded |
1887 #endif |
2052 #endif |
1888 GLDEF_C TInt E32Main() |
2053 GLDEF_C TInt E32Main() |