void Test_RtlInitializeBitMap(void) { RTL_BITMAP BitMapHeader; ULONG Buffer[2]; BOOLEAN Exception = FALSE; _SEH2_TRY { RtlInitializeBitMap(NULL, NULL, 0); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Exception = TRUE; } _SEH2_END; ok_int(Exception, 1); memset(Buffer, 0xcc, sizeof(Buffer)); RtlInitializeBitMap(&BitMapHeader, Buffer, 0); ok_int(BitMapHeader.SizeOfBitMap, 0); ok_ptr(BitMapHeader.Buffer, Buffer); ok_hex(Buffer[0], 0xcccccccc); RtlInitializeBitMap(&BitMapHeader, Buffer, 8); ok_int(BitMapHeader.SizeOfBitMap, 8); ok_hex(Buffer[0], 0xcccccccc); }
static void Test_Data(PTEST_IMAGE TestImage) { LDR_RESOURCE_INFO ResourceInfo; LDR_ENUM_RESOURCE_INFO EnumRes[8]; ULONG ResourceCount; NTSTATUS Status; InitializeTestImage(TestImage); memset(EnumRes, 0xcc, sizeof(EnumRes)); ResourceInfo.Type = 1; ResourceInfo.Name = 1; ResourceInfo.Language = 0x408; ResourceCount = 8; Status = LdrEnumResources(TestImage, &ResourceInfo, 0, &ResourceCount, EnumRes); ok_hex(Status, STATUS_SUCCESS); ok_dec(ResourceCount, 8); ok_ptr((PVOID)EnumRes[0].Data, TestImage->Resources.StringBuffer); ok_dec(EnumRes[0].Size, 2); ok_enumres(&EnumRes[0], 1, L"TEST", 0x409, TestImage->Resources.StringBuffer, 2) ok_enumres(&EnumRes[1], 1, L"TEST", 0x407, TestImage->Resources.StringBuffer + 2, 4) ok_enumres(&EnumRes[2], 1, 7, 0x408, TestImage->Resources.StringBuffer + 4, 6) ok_enumres(&EnumRes[3], 1, 7, 0x406, TestImage->Resources.StringBuffer + 6, 8) ok_enumres(&EnumRes[4], 2, L"LOL", 0x405, TestImage->Resources.StringBuffer + 8, 10) ok_enumres(&EnumRes[5], 2, L"LOL", 0x403, TestImage->Resources.StringBuffer + 10, 12) ok_enumres(&EnumRes[6], 2, L"xD", 0x402, TestImage->Resources.StringBuffer + 12, 14) ok_enumres(&EnumRes[7], 2, L"xD", 0x404, TestImage->Resources.StringBuffer + 14, 16) Status = LdrEnumResources(TestImage, &ResourceInfo, 1, &ResourceCount, EnumRes); ok_hex(Status, STATUS_SUCCESS); ok_dec(ResourceCount, 4); }
void Test_CreateBitmap() { HBITMAP hbmp; BITMAP bitmap; ULONG cjWidthBytes, cBitsPixel, cExpectedBitsPixel; int result, TestBitsPixel, ExpectedBitsPixel; hbmp = CreateBitmap(0, 0, 0, 0, NULL); ok(hbmp != 0, "should get a 1x1 bitmap\n"); ok(hbmp == GetStockObject(DEFAULT_BITMAP), "\n"); ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP)); ok_int(bitmap.bmType, 0); ok_int(bitmap.bmWidth, 1); ok_int(bitmap.bmHeight, 1); ok_int(bitmap.bmWidthBytes, 2); ok_int(bitmap.bmPlanes, 1); ok_int(bitmap.bmBitsPixel, 1); ok_ptr(bitmap.bmBits, 0); DeleteObject(hbmp); /* Above 32 bpp should fail */ hbmp = CreateBitmap(1, 2, 1, 33, NULL); ok(hbmp == 0, "should fail\n"); for (TestBitsPixel = 0; TestBitsPixel <= 32; TestBitsPixel++) { /* CreateBitmap API accepts any number as BitsPixels param. but it can only create 1, 4, 8, 16, 24, 32 bpp bitmaps */ if (TestBitsPixel <= 1) ExpectedBitsPixel = 1; else if(TestBitsPixel <= 4) ExpectedBitsPixel = 4; else if(TestBitsPixel <= 8) ExpectedBitsPixel = 8; else if(TestBitsPixel <= 16) ExpectedBitsPixel = 16; else if(TestBitsPixel <= 24) ExpectedBitsPixel = 24; else if(TestBitsPixel <= 32) ExpectedBitsPixel = 32; /* Calculate proper bmWidthBytes */ hbmp = CreateBitmap(1, 2, 1, TestBitsPixel, NULL); ok(hbmp != 0, "should get a 1x2 bitmap\n"); result = GetObject(hbmp, sizeof(bitmap), &bitmap); ok(result > 0, "result = %d\n", result); ok(bitmap.bmType == 0, "bmType = %ld\n", bitmap.bmType); ok(bitmap.bmWidth == 1, "bmWidth = %ld\n", bitmap.bmWidth); ok(bitmap.bmHeight == 2, "bmHeight = %ld\n", bitmap.bmHeight); ok(bitmap.bmPlanes == 1, "bmPlanes = %d\n", bitmap.bmPlanes); ok(bitmap.bmBitsPixel == ExpectedBitsPixel, "bmBitsPixel = %d ExpectedBitsPixel= %d \n", bitmap.bmBitsPixel, ExpectedBitsPixel); ok(bitmap.bmBits == 0, "bmBits = %p\n", bitmap.bmBits); DeleteObject(hbmp); } hbmp = CreateBitmap(1, 2, 1, 1, NULL); ok(hbmp != 0, "should get a 1x2 bitmap\n"); ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP)); ok_int(bitmap.bmType, 0); ok_int(bitmap.bmWidth, 1); ok_int(bitmap.bmHeight, 2); ok_int(bitmap.bmWidthBytes, 2); ok_int(bitmap.bmPlanes, 1); ok_int(bitmap.bmBitsPixel, 1); ok_ptr(bitmap.bmBits, 0); DeleteObject(hbmp); for (cBitsPixel = 0; cBitsPixel <= 32; cBitsPixel++) { /* CreateBitmap API accepts any number as BitsPixels param. but it just can create 1, 4, 8, 16, 24, 32 bpp Bitmaps */ if (cBitsPixel <= 1) cExpectedBitsPixel = 1; else if (cBitsPixel <= 4) cExpectedBitsPixel = 4; else if (cBitsPixel <= 8) cExpectedBitsPixel = 8; else if (cBitsPixel <= 16) cExpectedBitsPixel = 16; else if (cBitsPixel <= 24) cExpectedBitsPixel = 24; else if (cBitsPixel <= 32) cExpectedBitsPixel = 32; hbmp = CreateBitmap(1, 2, 1, cBitsPixel, NULL); ok(hbmp != 0, "should get a 1x2 bitmap %ld\n", cBitsPixel); ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP)); /* calculate expected line width */ cjWidthBytes = ((((ULONG)bitmap.bmWidth) * ((ULONG)bitmap.bmBitsPixel) + 15) & ~15) >> 3; ok_int(bitmap.bmType, 0); ok_int(bitmap.bmWidth, 1); ok_int(bitmap.bmHeight, 2); ok_int(bitmap.bmPlanes, 1); ok_int(bitmap.bmBitsPixel, cExpectedBitsPixel); ok_int(bitmap.bmWidthBytes, cjWidthBytes); ok_ptr(bitmap.bmBits, 0); DeleteObject(hbmp); } hbmp = CreateBitmap(1, 2, 1, 33, NULL); ok(hbmp == 0, "Expected failure for 33 bpp\n"); }
static VOID TestNodeName(VOID) { int Error; PADDRINFOA AddrInfo; ADDRINFOA Hints; struct { PCSTR NodeName; PCSTR ExpectedAddress; INT Flags; } Tests[] = { { "", LocalAddress }, { " ", NULL }, { "doesntexist.reactos.org", NULL }, { "localhost", "127.0.0.1" }, { "localhost:80", NULL }, { "7.8.9.10", "7.8.9.10", AI_NUMERICHOST }, { "0.0.0.0", "0.0.0.0", AI_NUMERICHOST }, { "255.255.255.255", "255.255.255.255", AI_NUMERICHOST }, { "0.0.0.0 ", "0.0.0.0", /* no AI_NUMERICHOST */ }, { "0.0.0.0:80", NULL }, { "0.0.0.0.0", NULL }, { "1.1.1.256", NULL }, { "1.2.3", NULL }, { "1.2.3.0x4", "1.2.3.4", AI_NUMERICHOST }, { "1.2.3.010", "1.2.3.8", AI_NUMERICHOST }, /* let's just assume this one doesn't change any time soon ;) */ { "google-public-dns-a.google.com", "8.8.8.8" }, }; const INT TestCount = sizeof(Tests) / sizeof(Tests[0]); INT i; /* make sure we don't get IPv6 responses */ ZeroMemory(&Hints, sizeof(Hints)); Hints.ai_family = AF_INET; trace("Nodes\n"); for (i = 0; i < TestCount; i++) { trace("%d: '%s'\n", i, Tests[i].NodeName); StartSeh() AddrInfo = InvalidPointer; Error = getaddrinfo(Tests[i].NodeName, NULL, &Hints, &AddrInfo); if (Tests[i].ExpectedAddress) { ok_dec(Error, 0); ok_dec(WSAGetLastError(), 0); ok(AddrInfo != NULL && AddrInfo != InvalidPointer, "AddrInfo = %p\n", AddrInfo); } else { ok_dec(Error, WSAHOST_NOT_FOUND); ok_dec(WSAGetLastError(), WSAHOST_NOT_FOUND); ok_ptr(AddrInfo, NULL); } if (!Error && AddrInfo && AddrInfo != InvalidPointer) { ok_addrinfo(AddrInfo, Tests[i].Flags, AF_INET, 0, 0, sizeof(SOCKADDR_IN)); ok_ptr(AddrInfo->ai_canonname, NULL); ok_sockaddr_in(AddrInfo->ai_addr, AF_INET, 0, Tests[i].ExpectedAddress); ok_ptr(AddrInfo->ai_next, NULL); freeaddrinfo(AddrInfo); } EndSeh(STATUS_SUCCESS); } }
static VOID TestServiceName(VOID) { int Error; PADDRINFOA AddrInfo; ADDRINFOA Hints; struct { PCSTR ServiceName; INT ExpectedPort; INT SockType; } Tests[] = { { "", 0 }, { "0", 0 }, { "1", 1 }, { "a", -1 }, { "010", 10 }, { "0x1a", -1 }, { "http", 80, SOCK_STREAM }, { "smtp", 25, SOCK_STREAM }, { "mail", 25, SOCK_STREAM }, /* alias for smtp */ { "router", 520, SOCK_DGRAM }, { "domain", 53, 0 /* DNS supports both UDP and TCP */ }, { ":0", -1 }, { "123", 123 }, { " 123", 123 }, { " 123", 123 }, { "32767", 32767 }, { "32768", 32768 }, { "65535", 65535 }, { "65536", 0 }, { "65537", 1 }, { "65540", 4 }, { "65536", 0 }, { "4294967295", 65535 }, { "4294967296", 65535 }, { "9999999999", 65535 }, { "999999999999999999999999999999999999", 65535 }, { "+5", 5 }, { "-1", 65535 }, { "-4", 65532 }, { "-65534", 2 }, { "-65535", 1 }, { "-65536", 0 }, { "-65537", 65535 }, { "28a", -1 }, { "28 ", -1 }, { "a28", -1 }, }; const INT TestCount = sizeof(Tests) / sizeof(Tests[0]); INT i; /* make sure we don't get IPv6 responses */ ZeroMemory(&Hints, sizeof(Hints)); Hints.ai_family = AF_INET; trace("Services\n"); for (i = 0; i < TestCount; i++) { trace("%d: '%s'\n", i, Tests[i].ServiceName); StartSeh() AddrInfo = InvalidPointer; Error = getaddrinfo(NULL, Tests[i].ServiceName, &Hints, &AddrInfo); if (Tests[i].ExpectedPort != -1) { ok_dec(Error, 0); ok_dec(WSAGetLastError(), 0); ok(AddrInfo != NULL && AddrInfo != InvalidPointer, "AddrInfo = %p\n", AddrInfo); } else { ok_dec(Error, WSATYPE_NOT_FOUND); ok_dec(WSAGetLastError(), WSATYPE_NOT_FOUND); ok_ptr(AddrInfo, NULL); } if (!Error && AddrInfo && AddrInfo != InvalidPointer) { ok_addrinfo(AddrInfo, 0, AF_INET, Tests[i].SockType, 0, sizeof(SOCKADDR_IN)); ok_ptr(AddrInfo->ai_canonname, NULL); ok_sockaddr_in(AddrInfo->ai_addr, AF_INET, Tests[i].ExpectedPort, "127.0.0.1"); ok_ptr(AddrInfo->ai_next, NULL); freeaddrinfo(AddrInfo); } EndSeh(STATUS_SUCCESS); } }