test: trandom.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# trandom.c File Reference

`#include <stdio.h>`
`#include <nt.h>`
`#include <ntrtl.h>`

Go to the source code of this file.

## Functions

int _CDECL | main (int argc, char *argv[])

## Function Documentation

int _CDECL main | ( | int | argc,
|  | char * | argv[]
| ) |

Definition at line 28 of file trandom.c.

References ASSERTMSG, CHAR, DbgPrint, RtlCharToInteger(), RtlIntegerToChar(), RtlRandom(), Seed, and TRUE.

    00032 {
    00033     ULONG Seed;
    00034     ULONG Temp;
    00035     ULONG i;
    00036     CHAR Str[64];
    00037
    00038     DbgPrint("Start IntegerToChar and CharToInteger Test\n");
    00039
    00040     Seed = 0x12345678;
    00041     RtlIntegerToChar(Seed, 2, sizeof(Str), Str);
    00042     DbgPrint("Seed = 0b%s\n", Str);
    00043     RtlCharToInteger(Str, 2, &Temp);
    00044     ASSERTMSG( "RtlCharToInteger(2)", (Seed == Temp) );
    00045
    00046     RtlIntegerToChar(Seed, 8, sizeof(Str), Str);
    00047     DbgPrint("Seed = 0o%s\n", Str);
    00048     RtlCharToInteger(Str, 8, &Temp);
    00049     ASSERTMSG( "RtlCharToInteger(8)", (Seed == Temp) );
    00050
    00051     RtlIntegerToChar(Seed, 10, sizeof(Str), Str);
    00052     DbgPrint("Seed = %s\n", Str);
    00053     RtlCharToInteger(Str, 10, &Temp);
    00054     ASSERTMSG( "RtlCharToInteger(10)", (Seed == Temp) );
    00055
    00056     RtlIntegerToChar(Seed, 16, -8, Str);
    00057     Str[ 8 ] = '\0';
    00058     DbgPrint("Seed = 0x%s\n", Str);
    00059     RtlCharToInteger(Str, 16, &Temp);
    00060     ASSERTMSG( "RtlCharToInteger(16)", (Seed == Temp) );
    00061
    00062     DbgPrint("End IntegerToChar and CharToInteger Test\n");
    00063
    00064     DbgPrint("Start RandomTest()\n");
    00065
    00066     Seed = 0;
    00067     for (i=0; i<2048; i++) {
    00068         if ((i % 3) == 0) {
    00069             DbgPrint("\n");
    00070         }
    00071
    00072         RtlRandom(&Seed);
    00073         DbgPrint("%p ", Seed);
    00074
    00075         RtlIntegerToChar(Seed, 16, sizeof(Str), Str);
    00076         DbgPrint("= %s ", Str);
    00077
    00078     }
    00079
    00080     DbgPrint("\n");
    00081
    00082     DbgPrint("End RandomTest()\n");
    00083
    00084     return TRUE;
    00085
    00086 }