Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

870 lines
23 KiB

/*++
Copyright (c) 1991-1996, Microsoft Corporation All rights reserved.
Module Name:
fstest.c
Abstract:
Test module for NLS API FoldString.
NOTE: This code was simply hacked together quickly in order to
test the different code modules of the NLS component.
This is NOT meant to be a formal regression test.
Revision History:
06-14-91 JulieB Created.
--*/
//
// Include Files.
//
#include "nlstest.h"
//
// Constant Declarations.
//
#define BUFSIZE 50
#define FS_INVALID_FLAGS ((DWORD)(~(MAP_FOLDCZONE | MAP_PRECOMPOSED | \
MAP_COMPOSITE | MAP_FOLDDIGITS)))
//
// Global Variables.
//
#define FoldSrc1 L"This Is A String"
#define FoldSrc2 L"This Is$ A Str,ing"
WCHAR FoldDest[BUFSIZE];
#define wcMultiComp L"\x0065\x0301\x0300"
#define wcCompDigitCZone L"\x0065\x0301\x0300\x00b2\xfe64"
#define wcFoldCompDigitCZone L"\x00e9\x0300\x0032\x003c"
#define wcPrecompDigitCZone L"\x00e9\x0300\x00b2\xfe64"
#define wcFoldPreDigitCZone L"\x0065\x0301\x0300\x0032\x003c"
//
// Forward Declarations.
//
BOOL
InitFoldStr();
int
FS_BadParamCheck();
int
FS_NormalCase();
int
FS_Ansi();
////////////////////////////////////////////////////////////////////////////
//
// TestFoldString
//
// Test routine for FoldStringW API.
//
// 06-14-91 JulieB Created.
////////////////////////////////////////////////////////////////////////////
int TestFoldString()
{
int ErrCount = 0; // error count
//
// Print out what's being done.
//
printf("\n\nTESTING FoldStringW...\n\n");
//
// Initialize global variables.
//
if (!InitFoldStr())
{
printf("\nABORTED TestFoldString: Could not Initialize.\n");
return (1);
}
//
// Test bad parameters.
//
ErrCount += FS_BadParamCheck();
//
// Test normal cases.
//
ErrCount += FS_NormalCase();
//
// Test Ansi version.
//
ErrCount += FS_Ansi();
//
// Print out result.
//
printf("\nFoldStringW: ERRORS = %d\n", ErrCount);
//
// Return total number of errors found.
//
return (ErrCount);
}
////////////////////////////////////////////////////////////////////////////
//
// InitFoldStr
//
// This routine initializes the global variables. If no errors were
// encountered, then it returns TRUE. Otherwise, it returns FALSE.
//
// 06-14-91 JulieB Created.
////////////////////////////////////////////////////////////////////////////
BOOL InitFoldStr()
{
//
// Return success.
//
return (TRUE);
}
////////////////////////////////////////////////////////////////////////////
//
// FS_BadParamCheck
//
// This routine passes in bad parameters to the API routines and checks to
// be sure they are handled properly. The number of errors encountered
// is returned to the caller.
//
// 06-14-91 JulieB Created.
////////////////////////////////////////////////////////////////////////////
int FS_BadParamCheck()
{
int NumErrors = 0; // error count - to be returned
int rc; // return code
//
// Null Pointers.
//
// Variation 1 - lpSrcStr = NULL
rc = FoldStringW( MAP_FOLDDIGITS,
NULL,
-1,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_PARAMETER,
"lpSrcStr NULL",
&NumErrors );
// Variation 2 - lpDestStr = NULL
rc = FoldStringW( MAP_FOLDDIGITS,
FoldSrc1,
-1,
NULL,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_PARAMETER,
"lpDestStr NULL",
&NumErrors );
//
// Bad Counts.
//
// Variation 1 - cbSrc = 0
rc = FoldStringW( MAP_FOLDDIGITS,
FoldSrc1,
0,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_PARAMETER,
"cbSrc = 0",
&NumErrors );
// Variation 2 - cbDest < 0
rc = FoldStringW( MAP_FOLDDIGITS,
FoldSrc1,
-1,
FoldDest,
-1 );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_PARAMETER,
"cbDest < 0",
&NumErrors );
//
// Zero or Invalid Flag Values.
//
// Variation 1 - dwMapFlags = invalid
rc = FoldStringW( FS_INVALID_FLAGS,
FoldSrc1,
-1,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_FLAGS,
"dwMapFlags invalid",
&NumErrors );
// Variation 2 - dwMapFlags = 0
rc = FoldStringW( 0,
FoldSrc1,
-1,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_FLAGS,
"dwMapFlags zero",
&NumErrors );
// Variation 3 - illegal combo comp
rc = FoldStringW( MAP_PRECOMPOSED | MAP_COMPOSITE,
FoldSrc1,
-1,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_FLAGS,
"illegal combo comp",
&NumErrors );
//
// Same Buffer Check.
//
// Variation 1 - same buffer
FoldDest[0] = 0;
rc = FoldStringW( MAP_FOLDDIGITS,
FoldDest,
-1,
FoldDest,
BUFSIZE );
CheckReturnBadParam( rc,
0,
ERROR_INVALID_PARAMETER,
"same buffer",
&NumErrors );
//
// Return total number of errors found.
//
return (NumErrors);
}
////////////////////////////////////////////////////////////////////////////
//
// FS_NormalCase
//
// This routine tests the normal cases of the API routine.
//
// 06-14-91 JulieB Created.
////////////////////////////////////////////////////////////////////////////
int FS_NormalCase()
{
int NumErrors = 0; // error count - to be returned
int rc; // return code
#ifdef PERF
DbgBreakPoint();
#endif
//
// cbDest = 0.
//
// Variation 1 - cbSrc = -1
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
-1,
FoldDest,
0 );
CheckReturnValidW( rc,
-1,
NULL,
FoldSrc1,
"cbDest (0) cbSrc (-1)",
&NumErrors );
// Variation 2 - cbSrc = value
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
WC_STRING_LEN_NULL(FoldSrc1),
FoldDest,
0 );
CheckReturnValidW( rc,
-1,
NULL,
FoldSrc1,
"cbDest (0) cbSrc (value)",
&NumErrors );
// Variation 3 - lpDestStr = NULL
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
FoldSrc1,
"cbDest (0) lpDestStr NULL",
&NumErrors );
//
// cbSrc.
//
// Variation 1 - cbSrc = -1
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
FoldSrc1,
"cbSrc (-1)",
&NumErrors );
// Variation 2 - cbSrc = value
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
WC_STRING_LEN(FoldSrc1),
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
WC_STRING_LEN(FoldSrc1),
FoldDest,
FoldSrc1,
"cbSrc (value)",
&NumErrors );
// Variation 3 - cbSrc = -1, no DestStr
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
FoldSrc1,
"cbSrc (-1), no DestStr",
&NumErrors );
// Variation 4 - cbSrc = value, no DestStr
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc1,
WC_STRING_LEN(FoldSrc1),
NULL,
0 );
CheckReturnValidW( rc,
WC_STRING_LEN(FoldSrc1),
NULL,
FoldSrc1,
"cbSrc (value), no DestStr",
&NumErrors );
//
// MAP_PRECOMPOSED Flag.
//
// Variation 1 - precomposed
rc = FoldStringW( MAP_PRECOMPOSED,
FoldSrc2,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
FoldSrc2,
"precomposed",
&NumErrors );
// Variation 2 - precomposed
rc = FoldStringW( MAP_PRECOMPOSED,
L"\x006e\x0303",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x00f1",
"precomposed (n tilde)",
&NumErrors );
// Variation 3 - precomposed
rc = FoldStringW( MAP_PRECOMPOSED,
L"\x006e\x0303",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x00f1",
"precomposed (n tilde), no DestStr",
&NumErrors );
// Variation 4 - precomposed
rc = FoldStringW( MAP_PRECOMPOSED,
L"\x0062\x0303",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0062\x0303",
"precomposed (b tilde)",
&NumErrors );
// Variation 5 - precomposed
rc = FoldStringW( MAP_PRECOMPOSED,
L"\x0062\x0303",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x0062\x0303",
"precomposed (b tilde), no DestStr",
&NumErrors );
//
// MAP_COMPOSITE Flag.
//
// Variation 1 - composite
rc = FoldStringW( MAP_COMPOSITE,
FoldSrc2,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
FoldSrc2,
"composite",
&NumErrors );
// Variation 2 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x00f1",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x006e\x0303",
"composite (n tilde)",
&NumErrors );
// Variation 3 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x00f1",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x006e\x0303",
"composite (n tilde), no DestStr",
&NumErrors );
// Variation 4 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x01c4",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0044\x017d",
"composite (dz hacek)",
&NumErrors );
// Variation 5 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x01c4",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x0044\x017d",
"composite (dz hacek), no DestStr",
&NumErrors );
// Variation 6 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x0062\x0303",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0062\x0303",
"composite (b tilde)",
&NumErrors );
// Variation 7 - composite
rc = FoldStringW( MAP_COMPOSITE,
L"\x0062\x0303",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x0062\x0303",
"composite (b tilde), no DestStr",
&NumErrors );
//
// MAP_FOLDCZONE Flag.
//
// Variation 1 - fold compatibility zone
rc = FoldStringW( MAP_FOLDCZONE,
FoldSrc2,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
FoldSrc2,
"fold czone",
&NumErrors );
// Variation 2 - fold compatibility zone
rc = FoldStringW( MAP_FOLDCZONE,
L"\x004a\xff24\xff22",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x004a\x0044\x0042",
"fold czone (JDB)",
&NumErrors );
// Variation 3 - fold compatibility zone
rc = FoldStringW( MAP_FOLDCZONE,
L"\x004a\xff24\xff22",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x004a\x0044\x0042",
"fold czone (JDB), no DestStr",
&NumErrors );
//
// MAP_FOLDDIGITS Flag.
//
// Variation 1 - fold digits
rc = FoldStringW( MAP_FOLDDIGITS,
FoldSrc2,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
FoldSrc2,
"fold digits",
&NumErrors );
// Variation 2 - fold digits
rc = FoldStringW( MAP_FOLDDIGITS,
L"\x00b2\x00b3",
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0032\x0033",
"fold digits (23)",
&NumErrors );
// Variation 3 - fold digits
rc = FoldStringW( MAP_FOLDDIGITS,
L"\x00b2\x00b3",
-1,
NULL,
0 );
CheckReturnValidW( rc,
-1,
NULL,
L"\x0032\x0033",
"fold digits (23), no DestStr",
&NumErrors );
//
// Check precomposed with multiple diacritics.
//
// Variation 1 - precomp, multi diacritics
rc = FoldStringW( MAP_PRECOMPOSED,
wcMultiComp,
3,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
2,
FoldDest,
L"\x00e9\x0300",
"precomp, multi diacritics",
&NumErrors );
// Variation 2 - precomp, czone
rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDCZONE,
wcCompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x00e9\x0300\x00b2\x003c",
"precomp, czone",
&NumErrors );
// Variation 3 - precomp, digits
rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDDIGITS,
wcCompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x00e9\x0300\x0032\xfe64",
"precomp, digits",
&NumErrors );
// Variation 4 - precomp, czone, digits
rc = FoldStringW( MAP_PRECOMPOSED | MAP_FOLDCZONE | MAP_FOLDDIGITS,
wcCompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x00e9\x0300\x0032\x003c",
"precomp, czone, digits",
&NumErrors );
//
// Check composite.
//
// Variation 1 - comp, czone
rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDCZONE,
wcPrecompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0065\x0301\x0300\x00b2\x003c",
"comp, czone",
&NumErrors );
// Variation 2 - comp, digits
rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDDIGITS,
wcPrecompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0065\x0301\x0300\x0032\xfe64",
"comp, digits",
&NumErrors );
// Variation 3 - comp, czone, digits
rc = FoldStringW( MAP_COMPOSITE | MAP_FOLDCZONE | MAP_FOLDDIGITS,
wcPrecompDigitCZone,
-1,
FoldDest,
BUFSIZE );
CheckReturnValidW( rc,
-1,
FoldDest,
L"\x0065\x0301\x0300\x0032\x003c",
"comp, czone, digits",
&NumErrors );
//
// Return total number of errors found.
//
return (NumErrors);
}
////////////////////////////////////////////////////////////////////////////
//
// FS_Ansi
//
// This routine tests the Ansi version of the API routine.
//
// 06-14-91 JulieB Created.
////////////////////////////////////////////////////////////////////////////
int FS_Ansi()
{
int NumErrors = 0; // error count - to be returned
int rc; // return code
BYTE pFoldDestA[BUFSIZE]; // ptr to buffer
//
// FoldStringA.
//
// Variation 1 - cbSrc = -1
rc = FoldStringA( MAP_PRECOMPOSED,
"AbCd",
-1,
pFoldDestA,
BUFSIZE );
CheckReturnValidA( rc,
-1,
pFoldDestA,
"AbCd",
NULL,
"A version cbSrc (-1)",
&NumErrors );
// Variation 2 - cbSrc = value
rc = FoldStringA( MAP_PRECOMPOSED,
"AbCd",
4,
pFoldDestA,
BUFSIZE );
CheckReturnValidA( rc,
4,
pFoldDestA,
"AbCd",
NULL,
"A version cbSrc (value)",
&NumErrors );
// Variation 3 - cbSrc = -1, no DestStr
rc = FoldStringA( MAP_PRECOMPOSED,
"AbCd",
-1,
NULL,
0 );
CheckReturnValidA( rc,
-1,
NULL,
"AbCd",
NULL,
"A version cbSrc (-1), no DestStr",
&NumErrors );
// Variation 4 - cbSrc = value, no DestStr
rc = FoldStringA( MAP_PRECOMPOSED,
"AbCd",
4,
NULL,
0 );
CheckReturnValidA( rc,
4,
NULL,
"AbCd",
NULL,
"A version cbSrc (value), no DestStr",
&NumErrors );
//
// Return total number of errors found.
//
return (NumErrors);
}