MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / TEST

Function TEST

Source/UnitTest/test_encode.cpp:32–63  ·  view source on GitHub ↗

@brief Input overflow tests for xy * z. */

Source from the content-addressed store, hash-verified

30
31/** @brief Input overflow tests for xy * z. */
32TEST(compress, overflow_in_z)
33{
34 astcenc_error status;
35 astcenc_config config;
36 astcenc_context* context;
37
38 static const astcenc_swizzle swizzle {
39 ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A
40 };
41
42 astcenc_config_init(ASTCENC_PRF_LDR, 4, 4, 1, ASTCENC_PRE_MEDIUM, 0, &config);
43 status = astcenc_context_alloc(&config, 1, &context, nullptr);
44 EXPECT_EQ(status, ASTCENC_SUCCESS);
45
46 // Arrays are too short, but should never be touched
47 uint8_t data[1];
48 uint8_t input[1];
49
50 astcenc_image image;
51 // x * y always fits in 64-bit size_t, but xy * z will overflow
52 image.dim_x = 0xFFFFFFFFu;
53 image.dim_y = 0xFFFFFFFFu;
54 image.dim_z = 0xFFFFFFFFu;
55 image.data_type = ASTCENC_TYPE_U8;
56 uint8_t* slices = input;
57 image.data = reinterpret_cast<void**>(&slices);
58
59 status = astcenc_compress_image(context, &image, &swizzle, data, -1, 0);
60 EXPECT_EQ(status, ASTCENC_ERR_BAD_PARAM);
61
62 astcenc_context_free(context);
63}
64
65/** @brief Input overflow tests for xyz * 16. */
66TEST(compress, overflow_in_16)

Callers

nothing calls this directly

Calls 5

astcenc_config_initFunction · 0.85
astcenc_context_allocFunction · 0.85
astcenc_compress_imageFunction · 0.85
astcenc_context_freeFunction · 0.85
run_positive_testFunction · 0.85

Tested by

no test coverage detected