trtl.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include <os2.h>
00022
#include <stdio.h>
00023
#include <process.h>
00024
#include "nt.h"
00025
#include "ntrtl.h"
00026
00027 char *
TestMemoryStrings[] = {
00028
"",
00029
"1",
00030
"12",
00031
"123",
00032
"1234",
00033
"12345",
00034
"123456",
00035
"1234567",
00036
"12345678",
00037
"123456789",
00038
"123456789A",
00039
NULL
00040 };
00041
00042
00043 BOOLEAN
00044 StringCompare(
00045 IN PSTRING String1,
00046 IN PSTRING String2,
00047 IN BOOLEAN CaseInSensitive,
00048 IN LONG ExpectedResult
00049 )
00050 {
00051 LONG Result =
RtlCompareString(
String1,
String2, CaseInSensitive );
00052
00053
if (Result < 0) {
00054 Result = -1
L;
00055 }
00056
else {
00057
if (Result > 0) {
00058 Result = 1
L;
00059 }
00060 }
00061
00062
if (Result != ExpectedResult) {
00063
DbgPrint(
"RtlCompareString( \"%.*s\", \"%.*s\", %d ) == %ld (%ld)\n",
00064
String1->Length,
String1->Buffer,
00065
String2->Length,
String2->Buffer,
00066 CaseInSensitive,
00067 Result, ExpectedResult
00068 );
00069
return(
FALSE );
00070 }
00071
else {
00072
return(
TRUE );
00073 }
00074 }
00075
00076 BOOLEAN
00077 StringEqual(
00078 IN PSTRING String1,
00079 IN PSTRING String2,
00080 IN BOOLEAN CaseInSensitive,
00081 IN BOOLEAN ExpectedResult
00082 )
00083 {
00084 BOOLEAN Result =
RtlEqualString(
String1,
String2, CaseInSensitive );
00085
00086
if (Result != ExpectedResult) {
00087
DbgPrint(
"RtlEqualString( \"%.*s\", \"%.*s\", %d ) == %d (%d)\n",
00088
String1->Length,
String1->Buffer,
00089
String2->Length,
String2->Buffer,
00090 CaseInSensitive,
00091 Result, ExpectedResult );
00092
return(
FALSE );
00093 }
00094
else {
00095
return(
TRUE );
00096 }
00097 }
00098
00099
VOID
00100 DumpString(
00101 IN PCH StringTitle,
00102 IN PSTRING String
00103 )
00104 {
00105
DbgPrint(
"%s: (%d, %d) \"%.*s\"\n", StringTitle,
00106
String->MaximumLength,
00107
String->Length,
00108
String->Length,
00109
String->Buffer );
00110 }
00111
00112
00113 BOOLEAN
00114 TestString(
void )
00115 {
00116 BOOLEAN Result;
00117
char buffer5[ 80 ], buffer6[ 15 ], buffer7[ 3 ];
00118 STRING
String1,
String2, String3, String4;
00119 STRING String5, String6, String7, String8;
00120
00121
00122
00123
RtlInitString( &
String1,
" One" );
00124
RtlInitString( &
String2,
" Two" );
00125
RtlInitString( &String3,
" Three" );
00126
RtlInitString( &String4,
" Four" );
00127 String5.Buffer = buffer5;
00128 String5.MaximumLength =
sizeof( buffer5 );
00129 String5.Length = 0;
00130 String6.Buffer = buffer6;
00131 String6.MaximumLength =
sizeof( buffer6 );
00132 String6.Length = 0;
00133 String7.Buffer = buffer7;
00134 String7.MaximumLength =
sizeof( buffer7 );
00135 String7.Length = 0;
00136 String8.Buffer =
NULL;
00137 String8.MaximumLength = 0;
00138 String8.Length = 0;
00139
RtlCopyString( &String5, &
String1 );
00140
RtlCopyString( &String6, &
String2 );
00141
RtlCopyString( &String7, &String3 );
00142
RtlCopyString( &String8, &String4 );
00143
00144
DumpString(
"String1", &
String1 );
00145
DumpString(
"String2", &
String2 );
00146
DumpString(
"String3", &String3 );
00147
DumpString(
"String4", &String4 );
00148
DumpString(
"String5", &String5 );
00149
DumpString(
"String6", &String6 );
00150
DumpString(
"String7", &String7 );
00151
DumpString(
"String8", &String8 );
00152
00153 Result =
TRUE;
00154 Result &=
StringCompare( &
String1, &
String1,
FALSE, 0
L );
00155 Result &=
StringCompare( &
String1, &
String2,
FALSE, -1
L);
00156 Result &=
StringCompare( &
String1, &String3,
FALSE, -1
L);
00157 Result &=
StringCompare( &
String1, &String4,
FALSE, 1
L );
00158 Result &=
StringCompare( &
String1, &String5,
FALSE, 0
L );
00159 Result &=
StringCompare( &
String1, &String6,
FALSE, -1
L);
00160 Result &=
StringCompare( &
String1, &String7,
FALSE, -1
L);
00161 Result &=
StringCompare( &
String1, &String8,
FALSE, 1
L );
00162
00163 Result &=
StringEqual( &
String1, &
String1,
FALSE, 1 );
00164 Result &=
StringEqual( &
String1, &
String2,
FALSE, 0 );
00165 Result &=
StringEqual( &
String1, &String3,
FALSE, 0 );
00166 Result &=
StringEqual( &
String1, &String4,
FALSE, 0 );
00167 Result &=
StringEqual( &
String1, &String5,
FALSE, 1 );
00168 Result &=
StringEqual( &
String1, &String6,
FALSE, 0 );
00169 Result &=
StringEqual( &
String1, &String7,
FALSE, 0 );
00170 Result &=
StringEqual( &
String1, &String8,
FALSE, 0 );
00171
00172
return( Result );
00173 }
00174
00175
00176
int
00177 _CDECL
00178 main(
00179
int argc,
00180
char *argv[]
00181 )
00182 {
00183
if (!
TestString()) {
00184
DbgPrint(
"TRTL: TestString failed\n" );
00185
exit( 1 );
00186 }
00187
00188
exit( 0 );
00189
return( 0 );
00190 }
Generated on Sat May 15 19:42:05 2004 for test by
1.3.7