Showing the changes to test/encoder/EncUT_MemoryAlloc.cpp (1 of 2 files). Show all
Unified · Split
| @@ -18,18 +18,20 @@ TEST(MemoryAlignTest, GetCacheLineSize_LoopWithin16K) { · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | TEST(MemoryAlignTest, GetCacheLineSize_Zero) { | 19 | TEST(MemoryAlignTest, GetCacheLineSize_Zero) { |
| 20 | CMemoryAlign cTestMa(0); | 20 | CMemoryAlign cTestMa(0); |
| 21 | ASSERT_EQ( 16, cTestMa.WelsGetCacheLineSize() ); | 21 | const uint32_t kuiSixteen = 16; |
| 22 | ASSERT_EQ( kuiSixteen, cTestMa.WelsGetCacheLineSize() ); | ||
| 22 | } | 23 | } |
| 23 | TEST(MemoryAlignTest, GetCacheLineSize_MaxUINT) { | 24 | TEST(MemoryAlignTest, GetCacheLineSize_MaxUINT) { |
| 24 | CMemoryAlign cTestMa(0xFFFFFFFF); | 25 | CMemoryAlign cTestMa(0xFFFFFFFF); |
| 25 | ASSERT_EQ( 16, cTestMa.WelsGetCacheLineSize() ); | 26 | const uint32_t kuiSixteen = 16; |
| 27 | ASSERT_EQ( kuiSixteen, cTestMa.WelsGetCacheLineSize() ); | ||
| 26 | } | 28 | } |
| 27 | //Tests of WelsGetCacheLineSize End | 29 | //Tests of WelsGetCacheLineSize End |
| 28 | //Tests of WelsMallocAndFree Begin | 30 | //Tests of WelsMallocAndFree Begin |
| 29 | TEST(MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) { | 31 | TEST(MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) { |
| 30 | const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8}; | 32 | const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8}; |
| 31 | srand((uint32_t)time(NULL)); | 33 | srand((uint32_t)time(NULL)); |
| 32 | 34 | const uint32_t kuiZero = 0; | |
| 33 | for (int i=0; i<4; i++) { | 35 | for (int i=0; i<4; i++) { |
| 34 | const uint32_t kuiTestAlignSize = kuiTargetAlignSize[i]; | 36 | const uint32_t kuiTestAlignSize = kuiTargetAlignSize[i]; |
| 35 | const uint32_t kuiTestDataSize = abs(rand()); | 37 | const uint32_t kuiTestDataSize = abs(rand()); |
| @@ -45,13 +47,13 @@ TEST(MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) { · 9 unmodified lines | |||
| 45 | ASSERT_TRUE( (((uintptr_t)(pUnitTestData)) & kuiExtraAlignSize) == 0 ); | 47 | ASSERT_TRUE( (((uintptr_t)(pUnitTestData)) & kuiExtraAlignSize) == 0 ); |
| 46 | EXPECT_EQ( kuiExpectedSize, cTestMa.WelsGetMemoryUsage() ); | 48 | EXPECT_EQ( kuiExpectedSize, cTestMa.WelsGetMemoryUsage() ); |
| 47 | cTestMa.WelsFree( pUnitTestData, strUnitTestTag ); | 49 | cTestMa.WelsFree( pUnitTestData, strUnitTestTag ); |
| 48 | EXPECT_EQ( 0, cTestMa.WelsGetMemoryUsage() ); | 50 | EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() ); |
| 49 | } | 51 | } |
| 50 | else { | 52 | else { |
| 51 | EXPECT_EQ( NULL, pUnitTestData ); | 53 | EXPECT_EQ( NULL, pUnitTestData ); |
| 52 | EXPECT_EQ( 0, cTestMa.WelsGetMemoryUsage() ); | 54 | EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() ); |
| 53 | cTestMa.WelsFree( pUnitTestData, strUnitTestTag ); | 55 | cTestMa.WelsFree( pUnitTestData, strUnitTestTag ); |
| 54 | EXPECT_EQ( 0, cTestMa.WelsGetMemoryUsage() ); | 56 | EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() ); |
| 55 | } | 57 | } |
| 56 | } | 58 | } |
| 57 | } | 59 | } |