本文整理汇总了C++中CHECK_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_EQUAL函数的具体用法?C++ CHECK_EQUAL怎么用?C++ CHECK_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_EQUAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_FIXTURE
TEST_FIXTURE(Matrix2Fixture, Determinant)
{
CHECK_EQUAL(mat1.det(), 1.0f);
CHECK_EQUAL(mat2.det(), 0.0f);
CHECK_EQUAL(mat4.det(), 0.0f);
}
示例2: TEST
TEST(SimpleString, CHECK_EQUAL_Uint8_t)
{
uint8_t i = 0xff;
CHECK_EQUAL(i, i);
}
示例3: TEST
TEST(SoundexEncoding, AppendsZerosToWordForOneLetterWord) {
CHECK_EQUAL("A000", soundex.encode("A"));
CHECK_EQUAL("B000", soundex.encode("B"));
}
示例4: TEST_FIXTURE
TEST_FIXTURE(TwoLists, Length)
{
CHECK_EQUAL(4u, length<string>(lst1));
CHECK_EQUAL(3u, length<string>(lst2));
}
示例5: TEST
TEST( Allocate_3_Top_down_free , MemoryShakeOut )
{
io::create("Student Values", "Test6.txt");
fprintf(io::getHandle(),"Test6: \n\n");
fprintf(io::getHandle()," 1) used \n");
fprintf(io::getHandle()," 2) used \n");
fprintf(io::getHandle()," 3) used \n");
fprintf(io::getHandle()," 4) top down free \n\n");
fprintf(io::getHandle()," memSystem mem; \n");
fprintf(io::getHandle()," mem.InitializeSystem(); \n");
fprintf(io::getHandle()," void *a = mem.Malloc( 0x200 ); \n");
fprintf(io::getHandle()," void *b = mem.Malloc( 0x200 ); \n");
fprintf(io::getHandle()," void *c = mem.Malloc( 0x200 ); \n");
fprintf(io::getHandle()," mem.dump(); \n");
fprintf(io::getHandle()," mem.Free( a ); \n");
fprintf(io::getHandle()," mem.dump(); \n");
fprintf(io::getHandle()," mem.Free( b ); \n");
fprintf(io::getHandle()," mem.dump(); \n");
fprintf(io::getHandle()," mem.Free( c ); \n");
fprintf(io::getHandle()," mem.dump(); \n");
// Part A:
memSystem mem1;
mem1.InitializeSystem();
void *a1 = mem1.Malloc( 0x200 );
void *b1 = mem1.Malloc( 0x200 );
void *c1 = mem1.Malloc( 0x200 );
mem1.dump();
// Part B:
mem1.Free( a1 );
mem1.dump();
// Part C:
mem1.Free( b1 );
mem1.dump();
// Part D:
mem1.Free( c1 );
mem1.dump();
io::destroy();
// ---- GENERAL CHECK ------------------------------------------------------
// ---- Part A: -------------------------------------------------------------
memSystem mem;
mem.InitializeSystem();
void *a = mem.Malloc( 0x200 );
void *b = mem.Malloc( 0x200 );
void *c = mem.Malloc( 0x200 );
// ---- Verify A: -----------------------------------------------------------
heapHdr *h = mem.getHeap();
// Sanit check, make sure everything is heap relative for testing
CHECK_EQUAL( PTR_FIX(h), 0 );
// Heap Start / Heap Bottom
CHECK_EQUAL( PTR_FIX(h->stats.heapTopAddr), 0x40 );
CHECK_EQUAL( PTR_FIX(h->stats.heapBottomAddr), HEAP_SIZE );
// Used / Free
CHECK_EQUAL( PTR_FIX(h->freeHead), 0x40 + 0x10 + 0x200 + 0x10 + 0x200 + 0x10 + 0x200);
CHECK_EQUAL( PTR_FIX(h->usedHead), 0x40 + 0x10 + 0x200 + 0x10 + 0x200 );
// ---- Heap Stats ------------------------------------------------------
CHECK_EQUAL( h->stats.peakNumUsed, 3 );
CHECK_EQUAL( h->stats.peakUsedMemory, 3*0x200);
CHECK_EQUAL( h->stats.currNumUsedBlocks, 3);
CHECK_EQUAL( h->stats.currUsedMem, 3*0x200 );
CHECK_EQUAL( h->stats.currNumFreeBlocks, 1 );
CHECK_EQUAL( h->stats.currFreeMem, 0xc180 );
CHECK_EQUAL( h->stats.sizeHeap, 0xc800 );
CHECK_EQUAL( h->stats.sizeHeapHeader, 0x40 );
CHECK_EQUAL( PTR_FIX( h->stats.heapTopAddr), 0x40 );
CHECK_EQUAL( PTR_FIX(h->stats.heapBottomAddr), 0xc800 );
// ---- Heap Walk ------------------------------------------------------
// ---- Heap Hdr -------------------------------------------------------
//.........这里部分代码省略.........
示例6: _passingCheckEqualTestMethod
static void _passingCheckEqualTestMethod()
{
CHECK_EQUAL(1, 1);
}
示例7: test2
static void test2(RTTEST hTest)
{
RTTestSub(hTest, "UTF-8 upper/lower encoding assumption");
#define CHECK_EQUAL(str1, str2) \
do \
{ \
RTTESTI_CHECK(strlen((str1).c_str()) == (str1).length()); \
RTTESTI_CHECK((str1).length() == (str2).length()); \
RTTESTI_CHECK(mymemcmp((str1).c_str(), (str2).c_str(), (str2).length() + 1) == 0); \
} while (0)
RTCString strTmp, strExpect;
char szDst[16];
/* Some simple ascii stuff. */
strTmp = "abcdefghijklmnopqrstuvwxyz0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
strExpect = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
strTmp.toUpper();
CHECK_EQUAL(strTmp, strExpect);
strTmp.toLower();
strExpect = "abcdefghijklmnopqrstuvwxyz0123456abcdefghijklmnopqrstuvwxyz;-+/\\";
CHECK_EQUAL(strTmp, strExpect);
strTmp = "abcdefghijklmnopqrstuvwxyz0123456ABCDEFGHIJKLMNOPQRSTUVWXYZ;-+/\\";
strTmp.toLower();
CHECK_EQUAL(strTmp, strExpect);
/* Collect all upper and lower case code points. */
RTCString strLower("");
strLower.reserve(_4M);
RTCString strUpper("");
strUpper.reserve(_4M);
for (RTUNICP uc = 1; uc <= 0x10fffd; uc++)
{
/* Unicode 4.01, I think, introduced a few codepoints with lower/upper mappings
that aren't up for roundtrips and which case folding has a different UTF-8
length. We'll just skip them here as there are very few:
- Dotless small i and dotless capital I folds into ASCII I and i.
- The small letter long s folds to ASCII S.
- Greek prosgegrammeni folds to iota, which is a letter with both upper
and lower case foldings of its own. */
if (uc == 0x131 || uc == 0x130 || uc == 0x17f || 0x1fbe)
continue;
if (RTUniCpIsLower(uc))
{
RTTESTI_CHECK_MSG(uc < 0xd800 || (uc > 0xdfff && uc != 0xfffe && uc != 0xffff), ("%#x\n", uc));
strLower.appendCodePoint(uc);
}
if (RTUniCpIsUpper(uc))
{
RTTESTI_CHECK_MSG(uc < 0xd800 || (uc > 0xdfff && uc != 0xfffe && uc != 0xffff), ("%#x\n", uc));
strUpper.appendCodePoint(uc);
}
}
RTTESTI_CHECK(strlen(strLower.c_str()) == strLower.length());
RTTESTI_CHECK(strlen(strUpper.c_str()) == strUpper.length());
/* Fold each code point in the lower case string and check that it encodes
into the same or less number of bytes. */
size_t cch = 0;
const char *pszCur = strLower.c_str();
RTCString strUpper2("");
strUpper2.reserve(strLower.length() + 64);
for (;;)
{
RTUNICP ucLower;
const char * const pszPrev = pszCur;
RTTESTI_CHECK_RC_BREAK(RTStrGetCpEx(&pszCur, &ucLower), VINF_SUCCESS);
size_t const cchSrc = pszCur - pszPrev;
if (!ucLower)
break;
RTUNICP const ucUpper = RTUniCpToUpper(ucLower);
const char *pszDstEnd = RTStrPutCp(szDst, ucUpper);
size_t const cchDst = pszDstEnd - &szDst[0];
RTTESTI_CHECK_MSG(cchSrc >= cchDst,
("ucLower=%#x %u bytes; ucUpper=%#x %u bytes\n",
ucLower, cchSrc, ucUpper, cchDst));
cch += cchDst;
strUpper2.appendCodePoint(ucUpper);
/* roundtrip stability */
RTUNICP const ucUpper2 = RTUniCpToUpper(ucUpper);
RTTESTI_CHECK_MSG(ucUpper2 == ucUpper, ("ucUpper2=%#x ucUpper=%#x\n", ucUpper2, ucUpper));
RTUNICP const ucLower2 = RTUniCpToLower(ucUpper);
RTTESTI_CHECK_MSG(ucLower2 == ucLower, ("ucLower2=%#x ucLower=%#x\n", ucLower2, ucLower));
RTUNICP const ucUpper3 = RTUniCpToUpper(ucLower2);
RTTESTI_CHECK_MSG(ucUpper3 == ucUpper, ("ucUpper3=%#x ucUpper=%#x\n", ucUpper3, ucUpper));
pszDstEnd = RTStrPutCp(szDst, ucLower2);
size_t const cchLower2 = pszDstEnd - &szDst[0];
RTTESTI_CHECK_MSG(cchDst == cchLower2,
("ucLower2=%#x %u bytes; ucUpper=%#x %u bytes; ucLower=%#x\n",
ucLower2, cchLower2, ucUpper, cchDst, ucLower));
//.........这里部分代码省略.........
示例8: TEST_FIXTURE
TEST_FIXTURE(fixture,ImageManager_AddProcedural_LUMINANCE) {
CHECK(iLib->_imageManager->add(testImage,800,600,IND_LUMINANCE));
CHECK_EQUAL(8,testImage->getBpp());
}
示例9: TEST_FIXTURE
TEST_FIXTURE(MatrixData, Operators)
{
CMatrix TestMatrix;
CMatrix Result;
float afArray[4] = {5,4,3,1};
Result.init(1,1);
TestMatrix.init(4,1);
TestMatrix.setCol (0,afArray,4);
//[ 0 0 0 0
// 0 1 2 3
// 0 2 4 6]
for (int i = 0; i < m_iNumRows; i++)
{
for (int j = 0; j < m_iNumCols; j++)
{
m_ppfBuff[i][j] = static_cast<float>(i*j);
Matrix.setElement(i,j, static_cast<float>(i*j));
}
}
//Result = TestMatrix * Matrix;
//CHECK_EQUAL(0, TestMatrix.getNumRows());
//CHECK_EQUAL(0, TestMatrix.getNumCols());
Result = Matrix * TestMatrix;
CHECK_EQUAL(m_iNumRows, Result.getNumRows());
CHECK_EQUAL(1, Result.getNumCols());
CHECK_EQUAL(0, Result.getElement(0,0));
CHECK_EQUAL(13, Result.getElement(1,0));
CHECK_EQUAL(26, Result.getElement(2,0));
TestMatrix = Matrix;
for (int i = 0; i < m_iNumRows; i++)
{
TestMatrix.getRow(i, afArray, m_iNumCols);
CHECK_ARRAY_EQUAL(m_ppfBuff[i],afArray, m_iNumCols);
}
TestMatrix = Matrix + Matrix;
for (int i = 0; i < m_iNumRows; i++)
{
for (int j = 0; j < m_iNumCols; j++)
{
CHECK_EQUAL(m_ppfBuff[i][j]*2,TestMatrix.getElement(i,j));
}
}
TestMatrix = Matrix * 2;
for (int i = 0; i < m_iNumRows; i++)
{
for (int j = 0; j < m_iNumCols; j++)
{
CHECK_EQUAL(m_ppfBuff[i][j]*2,TestMatrix.getElement(i,j));
}
}
TestMatrix = Matrix + 2.5F;
for (int i = 0; i < m_iNumRows; i++)
{
for (int j = 0; j < m_iNumCols; j++)
{
CHECK_EQUAL(m_ppfBuff[i][j]+2.5F,TestMatrix.getElement(i,j));
}
}
TestMatrix = TestMatrix - 2.5F;
for (int i = 0; i < m_iNumRows; i++)
{
for (int j = 0; j < m_iNumCols; j++)
{
CHECK_EQUAL(m_ppfBuff[i][j],TestMatrix.getElement(i,j));
}
}
TestMatrix = TestMatrix;
}
示例10: RunTest
virtual void RunTest (TestResult& result_)
{
CHECK_EQUAL (1, MyFunction());
}
示例11: TEST
TEST(RayTracer, can_calculate_image_plane) {
RayTracer rt(20, 10);
Vect viewDir = rt.getViewDirection();
CHECK_EQUAL(0, viewDir.getX());
CHECK_EQUAL(0, viewDir.getY());
CHECK_EQUAL(-1, viewDir.getZ());
Vect camPos = rt.getCameraPos();
CHECK_EQUAL(0, camPos.getX());
CHECK_EQUAL(0, camPos.getY());
CHECK_EQUAL(0, camPos.getZ());
Vect pRight = rt.getParallelRight();
CHECK_EQUAL(1, pRight.getX());
CHECK_EQUAL(0, pRight.getY());
CHECK_EQUAL(0, pRight.getZ());
Vect pUp = rt.getParallelUp();
CHECK_EQUAL(0, pUp.getX());
CHECK_EQUAL(1, pUp.getY());
CHECK_EQUAL(0, pUp.getZ());
Vect iCtr = rt.getImageCenter();
CHECK_EQUAL(0, iCtr.getX());
CHECK_EQUAL(0, iCtr.getY());
CHECK_EQUAL(-100, iCtr.getZ());
}
示例12: TEST_FIXTURE
TEST_FIXTURE(EnchantBrokerTestFixture,
EnchantBrokerDictExists_ProviderImplementsNoMethods_0)
{
CHECK_EQUAL(0, enchant_broker_dict_exists(_broker, "en_GB"));
}
示例13: TEST
TEST( Allocate_Everything , MemoryShakeOut )
{
io::create("Hector Medina", "Test2.txt");
fprintf(io::getHandle(),"Test2: \n\n");
fprintf(io::getHandle(),"1) allocate the biggest block \n");
fprintf(io::getHandle()," memSystem mem; \n");
fprintf(io::getHandle()," mem.InitializeSystem(); \n");
fprintf(io::getHandle()," void *p = mem.Malloc( 0xc7b0 ); \n");
fprintf(io::getHandle()," mem.dump(); \n");
memSystem mem;
mem.InitializeSystem();
void *p = mem.Malloc( 0xc7b0 );
mem.dump();
p; // to shut up warnings
io::destroy();
// ---- GENERAL CHECK ------------------------------------------------------
heapHdr *h = mem.getHeap();
// Sanit check, make sure everything is heap relative for testing
CHECK_EQUAL( PTR_FIX(h), 0 );
// Heap Start / Heap Bottom
CHECK_EQUAL( PTR_FIX(h->stats.heapTopAddr), 0x40 );
CHECK_EQUAL( PTR_FIX(h->stats.heapBottomAddr), HEAP_SIZE );
// Used / Free
CHECK_EQUAL( PTR_FIX(h->freeHead), 0 );
CHECK_EQUAL( PTR_FIX(h->usedHead), 0x40);
// ---- Heap Stats ------------------------------------------------------
CHECK_EQUAL( h->stats.peakNumUsed, 1 );
CHECK_EQUAL( h->stats.peakUsedMemory, 0xc7b0 );
CHECK_EQUAL( h->stats.currNumUsedBlocks, 1 );
CHECK_EQUAL( h->stats.currUsedMem, 0xc7b0 );
CHECK_EQUAL( h->stats.currNumFreeBlocks, 0 );
CHECK_EQUAL( h->stats.currFreeMem, 0x0 );
CHECK_EQUAL( h->stats.sizeHeap, 0xc800 );
CHECK_EQUAL( h->stats.sizeHeapHeader, 0x40 );
CHECK_EQUAL( PTR_FIX( h->stats.heapTopAddr), 0x40 );
CHECK_EQUAL( PTR_FIX(h->stats.heapBottomAddr), 0xc800 );
// ---- Heap Walk ------------------------------------------------------
// ---- Heap Hdr -------------------------------------------------------
// HeapHdr Start
CHECK_EQUAL( PTR_FIX( (memU32)h->stats.heapTopAddr-sizeof(heapHdr) ), 0 );
// HeapHdr End
CHECK_EQUAL( PTR_FIX(h->stats.heapTopAddr), h->stats.sizeHeapHeader );
// HeapHdr Size
CHECK_EQUAL( h->stats.sizeHeapHeader, sizeof(heapHdr) );
// ---- Block walk ------------------------------------------------------
memU32 hdrStart;
memU32 hdrEnd;
memU32 blkStart;
memU32 blkEnd;
// ---- HDR -------------------------------------------
// Check type
usedHdr *used = (usedHdr *) h->stats.heapTopAddr;
// Should be USED
CHECK_EQUAL( (int)used->blockType, 0xAA );
hdrStart = (memU32)used;
hdrEnd = (memU32)used + sizeof(usedHdr);
// Hdr Start
CHECK_EQUAL( PTR_FIX(hdrStart), 0x40 );
// Hdr End
CHECK_EQUAL( PTR_FIX(hdrEnd), 0x50 );
// Prev
CHECK_EQUAL( PTR_FIX(used->usedPrev), 0 );
// Next
CHECK_EQUAL( PTR_FIX(used->usedNext), 0 );
// Hdr Size
CHECK_EQUAL( hdrEnd - hdrStart, sizeof(usedHdr) );
// ---- BLOCK ----------------------------------------------------
blkStart = hdrEnd;
blkEnd = blkStart + used->blockSize;
//.........这里部分代码省略.........
示例14: TEST
TEST(UnitTestMacros, failing_CHECK_EQUAL_withParamatersThatDontChangeWillNotGiveAnyWarning)
{
fixture.runTestWithMethod(_failingTestMethodWithCHECK_EQUAL);
CHECK( ! fixture.output_->getOutput().contains("WARNING"));
}
TEST(UnitTestMacros, CHECK_EQUALBehavesAsProperMacro)
{
if (false) CHECK_EQUAL(1, 2)
else CHECK_EQUAL(1, 1)
}
IGNORE_TEST(UnitTestMacros, CHECK_EQUALWorksInAnIgnoredTest)
{
CHECK_EQUAL(1, 2) // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
static void _failingTestMethodWithCHECK_EQUAL_TEXT()
{
CHECK_EQUAL_TEXT(1, 2, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, FailureWithCHECK_EQUAL_TEXT)
{
fixture.runTestWithMethod(_failingTestMethodWithCHECK_EQUAL_TEXT);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <2>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
}
示例15: check_service_properties
void check_service_properties(const azure::storage::service_properties& a, const azure::storage::service_properties& b)
{
CHECK_UTF8_EQUAL(a.logging().version(), b.logging().version());
CHECK_EQUAL(a.logging().delete_enabled(), b.logging().delete_enabled());
CHECK_EQUAL(a.logging().read_enabled(), b.logging().read_enabled());
CHECK_EQUAL(a.logging().write_enabled(), b.logging().write_enabled());
CHECK_EQUAL(a.logging().retention_policy_enabled(), b.logging().retention_policy_enabled());
CHECK_EQUAL(a.logging().retention_days(), b.logging().retention_days());
CHECK_UTF8_EQUAL(a.hour_metrics().version(), b.hour_metrics().version());
CHECK_EQUAL(a.hour_metrics().enabled(), b.hour_metrics().enabled());
if (a.hour_metrics().enabled())
{
CHECK_EQUAL(a.hour_metrics().include_apis(), b.hour_metrics().include_apis());
}
CHECK_EQUAL(a.hour_metrics().retention_policy_enabled(), b.hour_metrics().retention_policy_enabled());
CHECK_EQUAL(a.hour_metrics().retention_days(), b.hour_metrics().retention_days());
CHECK_UTF8_EQUAL(a.minute_metrics().version(), b.minute_metrics().version());
CHECK_EQUAL(a.minute_metrics().enabled(), b.minute_metrics().enabled());
if (a.minute_metrics().enabled())
{
CHECK_EQUAL(a.minute_metrics().include_apis(), b.minute_metrics().include_apis());
}
CHECK_EQUAL(a.minute_metrics().retention_policy_enabled(), b.minute_metrics().retention_policy_enabled());
CHECK_EQUAL(a.minute_metrics().retention_days(), b.minute_metrics().retention_days());
auto a_iter = a.cors().cbegin();
auto b_iter = b.cors().cbegin();
for (; a_iter != a.cors().cend() && b_iter != b.cors().cend(); ++a_iter, ++b_iter)
{
CHECK(std::equal(a_iter->allowed_headers().cbegin(), a_iter->allowed_headers().cend(), b_iter->allowed_headers().cbegin()));
CHECK(std::equal(a_iter->allowed_methods().cbegin(), a_iter->allowed_methods().cend(), b_iter->allowed_methods().cbegin()));
CHECK(std::equal(a_iter->allowed_origins().cbegin(), a_iter->allowed_origins().cend(), b_iter->allowed_origins().cbegin()));
CHECK(std::equal(a_iter->exposed_headers().cbegin(), a_iter->exposed_headers().cend(), b_iter->exposed_headers().cbegin()));
CHECK_EQUAL(a_iter->max_age().count(), b_iter->max_age().count());
}
CHECK(a_iter == a.cors().cend());
CHECK(b_iter == b.cors().cend());
// TODO: Is the following check valid?
//CHECK_UTF8_EQUAL(a.default_service_version(), b.default_service_version());
}