test: pixels: Use unsigned numeric literals
This fixes type promotion issues with the swap32 macro.pull/69/merge
parent
e6931239bc
commit
1081ff35cd
|
@ -10,7 +10,7 @@
|
|||
#define swap32(x) (((x >> 24) & 0xff) | ((x << 8) & 0xff0000) | \
|
||||
((x >> 8) & 0xff00) | ((x << 24) & 0xff000000))
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#if 0 //__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define u32_le(x) x
|
||||
#else
|
||||
#define u32_le(x) swap32(x)
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
static bool test_pixel32_to_cpixel_4bpp(void)
|
||||
{
|
||||
uint32_t src = u32_le(0x11223344);
|
||||
uint32_t src = u32_le(0x11223344u);
|
||||
uint32_t dst;
|
||||
|
||||
struct rfb_pixel_format dstfmt = { 0 }, srcfmt = { 0 };
|
||||
|
@ -34,25 +34,25 @@ static bool test_pixel32_to_cpixel_4bpp(void)
|
|||
dst = 0;
|
||||
rfb_pixfmt_from_fourcc(&srcfmt, DRM_FORMAT_RGBA8888);
|
||||
pixel32_to_cpixel((uint8_t*)&dst, &dstfmt, &src, &srcfmt, 4, 1);
|
||||
if ((src & 0xffffff00) != (dst & 0xffffff00))
|
||||
if ((src & 0xffffff00u) != (dst & 0xffffff00u))
|
||||
return false;
|
||||
|
||||
dst = 0;
|
||||
rfb_pixfmt_from_fourcc(&dstfmt, DRM_FORMAT_ABGR8888);
|
||||
pixel32_to_cpixel((uint8_t*)&dst, &dstfmt, &src, &srcfmt, 4, 1);
|
||||
if (dst != u32_le(0x00332211))
|
||||
if (dst != u32_le(0x00332211u))
|
||||
return false;
|
||||
|
||||
dst = 0;
|
||||
rfb_pixfmt_from_fourcc(&dstfmt, DRM_FORMAT_ARGB8888);
|
||||
pixel32_to_cpixel((uint8_t*)&dst, &dstfmt, &src, &srcfmt, 4, 1);
|
||||
if (dst != u32_le(0x00112233))
|
||||
if (dst != u32_le(0x00112233u))
|
||||
return false;
|
||||
|
||||
dst = 0;
|
||||
rfb_pixfmt_from_fourcc(&dstfmt, DRM_FORMAT_BGRA8888);
|
||||
pixel32_to_cpixel((uint8_t*)&dst, &dstfmt, &src, &srcfmt, 4, 1);
|
||||
if (dst != u32_le(0x33221100))
|
||||
if (dst != u32_le(0x33221100u))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -87,14 +87,14 @@ static bool test_fourcc_to_pixman_fmt(void)
|
|||
static bool test_extract_alpha_mask_rgba8888(void)
|
||||
{
|
||||
uint32_t test_data[] = {
|
||||
u32_le(0x00000000), // Black, transparent
|
||||
u32_le(0xff000000), // Red, transparent
|
||||
u32_le(0x00ff0000), // Red, transparent
|
||||
u32_le(0x0000ff00), // Green, transparent
|
||||
u32_le(0x000000ff), // Black, opaque
|
||||
u32_le(0xff0000ff), // Red, opaque
|
||||
u32_le(0x00ff00ff), // Red, opaque
|
||||
u32_le(0x0000ffff), // Green, opaque
|
||||
u32_le(0x00000000u), // Black, transparent
|
||||
u32_le(0xff000000u), // Red, transparent
|
||||
u32_le(0x00ff0000u), // Red, transparent
|
||||
u32_le(0x0000ff00u), // Green, transparent
|
||||
u32_le(0x000000ffu), // Black, opaque
|
||||
u32_le(0xff0000ffu), // Red, opaque
|
||||
u32_le(0x00ff00ffu), // Red, opaque
|
||||
u32_le(0x0000ffffu), // Green, opaque
|
||||
};
|
||||
|
||||
uint8_t mask[UDIV_UP(ARRAY_LEN(test_data), 8)] = { 0 };
|
||||
|
|
Loading…
Reference in New Issue