|
| 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_.wstr_ ) |
| 8 | + |
| 9 | + #macro check( dtype, value ) |
| 10 | + |
| 11 | + scope |
| 12 | + dim t as dtype = value |
| 13 | + dim w as wstring * 50 = wstr( t ) |
| 14 | + dim u as ustring = wstr( t ) |
| 15 | + dim r as wstring * 50 = u |
| 16 | + CU_ASSERT_WSTRING_EQUAL( w, r ) |
| 17 | + end scope |
| 18 | + |
| 19 | + #endmacro |
| 20 | + |
| 21 | + TEST( numeric ) |
| 22 | + |
| 23 | + check( byte, -128 ) |
| 24 | + check( byte, -0 ) |
| 25 | + check( byte, 127 ) |
| 26 | + |
| 27 | + check( ubyte, 0 ) |
| 28 | + check( ubyte, 128 ) |
| 29 | + check( ubyte, 255 ) |
| 30 | + |
| 31 | + check( short, -32768 ) |
| 32 | + check( short, 0 ) |
| 33 | + check( short, 32767 ) |
| 34 | + |
| 35 | + check( ushort, 0 ) |
| 36 | + check( ushort, 32768 ) |
| 37 | + check( ushort, 65535 ) |
| 38 | + |
| 39 | + check( long, -2147483648ll ) |
| 40 | + check( long, 0 ) |
| 41 | + check( long, 2147483647ull ) |
| 42 | + |
| 43 | + check( ulong, 0 ) |
| 44 | + check( ulong, 2147483648ull ) |
| 45 | + check( ulong, 4294967295ull ) |
| 46 | + |
| 47 | + check( longint, (-9223372036854775807ll-1ll) ) |
| 48 | + check( longint, 0 ) |
| 49 | + check( longint, 9223372036854775807ull ) |
| 50 | + |
| 51 | + check( ulongint, 0 ) |
| 52 | + check( ulongint, 9223372036854775808ull ) |
| 53 | + check( ulongint, 18446744073709551615ull ) |
| 54 | + |
| 55 | + check( single, -1.5 ) |
| 56 | + check( single, -1.0 ) |
| 57 | + check( single, -1.0 ) |
| 58 | + check( single, -0.5 ) |
| 59 | + check( single, 0.0 ) |
| 60 | + check( single, 0.5 ) |
| 61 | + check( single, 1.0) |
| 62 | + check( single, 1.5 ) |
| 63 | + check( single, 2.0 ) |
| 64 | + check( single, 2.5 ) |
| 65 | + |
| 66 | + check( double, -1.5 ) |
| 67 | + check( double, -1.0 ) |
| 68 | + check( double, -1.0 ) |
| 69 | + check( double, -0.5 ) |
| 70 | + check( double, 0.0 ) |
| 71 | + check( double, 0.5 ) |
| 72 | + check( double, 1.0) |
| 73 | + check( double, 1.5 ) |
| 74 | + check( double, 2.0 ) |
| 75 | + check( double, 2.5 ) |
| 76 | + |
| 77 | + END_TEST |
| 78 | + |
| 79 | + TEST( default ) |
| 80 | + |
| 81 | + dim s1 as wstring * 10 = wchr(1234) |
| 82 | + dim s2 as wstring * 10 = wchr(1234) |
| 83 | + dim s3 as wstring * 10 = wstr( s1 ) |
| 84 | + |
| 85 | + dim u1 as ustring = wchr(1234) |
| 86 | + dim u2 as ustring = wchr(1234) |
| 87 | + dim u3 as ustring = wstr( s1 ) |
| 88 | + dim u4 as ustring = wstr( u1 ) |
| 89 | + |
| 90 | + dim s4 as wstring * 10 = wstr( u1 ) |
| 91 | + |
| 92 | + dim r1 as wstring * 10 = u1 |
| 93 | + dim r2 as wstring * 10 = u2 |
| 94 | + dim r3 as wstring * 10 = u3 |
| 95 | + dim r4 as wstring * 10 = u4 |
| 96 | + |
| 97 | + #macro check_group( g ) |
| 98 | + |
| 99 | + CU_ASSERT_WSTRING_EQUAL( g, s1 ) |
| 100 | + CU_ASSERT_WSTRING_EQUAL( g, s2 ) |
| 101 | + CU_ASSERT_WSTRING_EQUAL( g, s3 ) |
| 102 | + CU_ASSERT_WSTRING_EQUAL( g, s4 ) |
| 103 | + |
| 104 | + CU_ASSERT_WSTRING_EQUAL( g, r1 ) |
| 105 | + CU_ASSERT_WSTRING_EQUAL( g, r2 ) |
| 106 | + CU_ASSERT_WSTRING_EQUAL( g, r3 ) |
| 107 | + CU_ASSERT_WSTRING_EQUAL( g, r4 ) |
| 108 | + |
| 109 | + #endmacro |
| 110 | + |
| 111 | + check_group( s1 ) |
| 112 | + check_group( s2 ) |
| 113 | + check_group( s3 ) |
| 114 | + check_group( s4 ) |
| 115 | + check_group( r1 ) |
| 116 | + check_group( r2 ) |
| 117 | + check_group( r3 ) |
| 118 | + check_group( r4 ) |
| 119 | + |
| 120 | + END_TEST |
| 121 | + |
| 122 | +END_SUITE |
0 commit comments