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.

86 lines
1.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. trandom.c
  5. Abstract:
  6. Test program for the random number generator
  7. Author:
  8. Gary Kimura [GaryKi] 26-May-1989
  9. Revision History:
  10. --*/
  11. #include <stdio.h>
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. int
  15. _CDECL
  16. main(
  17. int argc,
  18. char *argv[]
  19. )
  20. {
  21. ULONG Seed;
  22. ULONG Temp;
  23. ULONG i;
  24. CHAR Str[64];
  25. DbgPrint("Start IntegerToChar and CharToInteger Test\n");
  26. Seed = 0x12345678;
  27. RtlIntegerToChar(Seed, 2, sizeof(Str), Str);
  28. DbgPrint("Seed = 0b%s\n", Str);
  29. RtlCharToInteger(Str, 2, &Temp);
  30. ASSERTMSG( "RtlCharToInteger(2)", (Seed == Temp) );
  31. RtlIntegerToChar(Seed, 8, sizeof(Str), Str);
  32. DbgPrint("Seed = 0o%s\n", Str);
  33. RtlCharToInteger(Str, 8, &Temp);
  34. ASSERTMSG( "RtlCharToInteger(8)", (Seed == Temp) );
  35. RtlIntegerToChar(Seed, 10, sizeof(Str), Str);
  36. DbgPrint("Seed = %s\n", Str);
  37. RtlCharToInteger(Str, 10, &Temp);
  38. ASSERTMSG( "RtlCharToInteger(10)", (Seed == Temp) );
  39. RtlIntegerToChar(Seed, 16, -8, Str);
  40. Str[ 8 ] = '\0';
  41. DbgPrint("Seed = 0x%s\n", Str);
  42. RtlCharToInteger(Str, 16, &Temp);
  43. ASSERTMSG( "RtlCharToInteger(16)", (Seed == Temp) );
  44. DbgPrint("End IntegerToChar and CharToInteger Test\n");
  45. DbgPrint("Start RandomTest()\n");
  46. Seed = 0;
  47. for (i=0; i<2048; i++) {
  48. if ((i % 3) == 0) {
  49. DbgPrint("\n");
  50. }
  51. RtlRandom(&Seed);
  52. DbgPrint("%p ", Seed);
  53. RtlIntegerToChar(Seed, 16, sizeof(Str), Str);
  54. DbgPrint("= %s ", Str);
  55. }
  56. DbgPrint("\n");
  57. DbgPrint("End RandomTest()\n");
  58. return TRUE;
  59. }