Source code of Windows XP (NT5)
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.

101 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. tnlsxlat.c
  5. Abstract:
  6. Test program for the Nlsxlat Procedures
  7. Author:
  8. Ian James [IanJa] 03-Feb-1994
  9. Revision History:
  10. --*/
  11. #include <stdio.h>
  12. #include "nt.h"
  13. #include "ntrtl.h"
  14. #define NELEM(p) (sizeof(p) / sizeof(*(p)))
  15. char OEMBuff[1000];
  16. char ABuff[1000];
  17. WCHAR UBuff[2000];
  18. int
  19. main(
  20. int argc,
  21. char *argv[]
  22. )
  23. {
  24. ULONG j;
  25. ULONG cb;
  26. char *pch;
  27. printf("Start NlsXlatTest()\n");
  28. //
  29. // First initialize the buffers
  30. //
  31. for (j = 0; j < sizeof(OEMBuff); j++) {
  32. OEMBuff[j] = (char)(j * 17);
  33. ABuff[j] = (char)(j * 19);
  34. }
  35. //
  36. // TEST 1
  37. // RtlMultiByteToUnicodeN, RtlUnicodeToMultiByteN
  38. //
  39. printf("Test 1: MultiByteToUnicodeN & RtlUnicodeToMultiByteN\n");
  40. // TEST 1.1
  41. //
  42. printf(" Test 1.1: A->U U->A\n");
  43. RtlMultiByteToUnicodeN(UBuff, sizeof(UBuff), &cb, ABuff, sizeof(ABuff));
  44. printf(" %d bytes converted to Unicode\n", cb);
  45. RtlUnicodeToMultiByteN(ABuff, sizeof(ABuff), &cb, UBuff, sizeof(UBuff));
  46. printf(" %d bytes converted back to ANSI\n", cb);
  47. for (j = 0; j < sizeof(ABuff); j++) {
  48. if (ABuff[j] != (char)(j * 19)) {
  49. printf("ABuff[%d] was 0x%02x, now 0x%02x\n",
  50. j, (char)(j * 19), ABuff[j]);
  51. return FALSE;
  52. }
  53. }
  54. printf(" Test 1.1 OK\n");
  55. // TEST 1.2
  56. //
  57. printf(" Test 1.2: A->U U->A (source & dest buffers the same)\n");
  58. RtlCopyMemory(UBuff, ABuff, sizeof(ABuff));
  59. RtlMultiByteToUnicodeN(UBuff, sizeof(UBuff), &cb, UBuff, sizeof(ABuff));
  60. printf(" %d bytes converted to Unicode\n", cb);
  61. RtlUnicodeToMultiByteN(UBuff, sizeof(ABuff), &cb, UBuff, sizeof(UBuff));
  62. printf(" %d bytes converted back to ANSI\n", cb);
  63. pch = (LPSTR)UBuff;
  64. for (j = 0; j < sizeof(ABuff); j++) {
  65. if (pch[j] != ABuff[j]) {
  66. printf(" ABuff[%d] was 0x%02x, was turned into 0x%02x\n",
  67. j, ABuff[j], pch[j]);
  68. printf(" Test 1.2 FAILED!\n");
  69. return FALSE;
  70. }
  71. }
  72. printf(" Test 1.2 OK!\n");
  73. return TRUE;
  74. }