135375f98Sopenharmony_ci/* ==========================================
235375f98Sopenharmony_ci    Unity Project - A Test Framework for C
335375f98Sopenharmony_ci    Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
435375f98Sopenharmony_ci    [Released under MIT License. Please refer to license.txt for details]
535375f98Sopenharmony_ci========================================== */
635375f98Sopenharmony_ci
735375f98Sopenharmony_ci#include "unity.h"
835375f98Sopenharmony_ci#define TEST_INSTANCES
935375f98Sopenharmony_ci#include "self_assessment_utils.h"
1035375f98Sopenharmony_ci
1135375f98Sopenharmony_cistatic int SetToOneToFailInTearDown;
1235375f98Sopenharmony_cistatic int SetToOneMeanWeAlreadyCheckedThisGuy;
1335375f98Sopenharmony_ci
1435375f98Sopenharmony_civoid setUp(void)
1535375f98Sopenharmony_ci{
1635375f98Sopenharmony_ci    SetToOneToFailInTearDown = 0;
1735375f98Sopenharmony_ci    SetToOneMeanWeAlreadyCheckedThisGuy = 0;
1835375f98Sopenharmony_ci}
1935375f98Sopenharmony_ci
2035375f98Sopenharmony_civoid tearDown(void)
2135375f98Sopenharmony_ci{
2235375f98Sopenharmony_ci    endPutcharSpy(); /* Stop suppressing test output */
2335375f98Sopenharmony_ci    if (SetToOneToFailInTearDown == 1)
2435375f98Sopenharmony_ci    {
2535375f98Sopenharmony_ci        /* These will be skipped internally if already failed/ignored */
2635375f98Sopenharmony_ci        TEST_FAIL_MESSAGE("<= Failed in tearDown");
2735375f98Sopenharmony_ci        TEST_IGNORE_MESSAGE("<= Ignored in tearDown");
2835375f98Sopenharmony_ci    }
2935375f98Sopenharmony_ci    if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
3035375f98Sopenharmony_ci    {
3135375f98Sopenharmony_ci        UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
3235375f98Sopenharmony_ci        UNITY_OUTPUT_CHAR('\n');
3335375f98Sopenharmony_ci    }
3435375f98Sopenharmony_ci}
3535375f98Sopenharmony_ci
3635375f98Sopenharmony_civoid testEqualMemory(void)
3735375f98Sopenharmony_ci{
3835375f98Sopenharmony_ci    const char *testString = "whatever";
3935375f98Sopenharmony_ci
4035375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(testString, testString, 8);
4135375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY("whatever", "whatever", 8);
4235375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY("whatever", testString, 8);
4335375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 8);
4435375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(testString, "whatever", 2);
4535375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 1);
4635375f98Sopenharmony_ci}
4735375f98Sopenharmony_ci
4835375f98Sopenharmony_civoid testNotEqualMemory1(void)
4935375f98Sopenharmony_ci{
5035375f98Sopenharmony_ci    EXPECT_ABORT_BEGIN
5135375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY("foo", "bar", 3);
5235375f98Sopenharmony_ci    VERIFY_FAILS_END
5335375f98Sopenharmony_ci}
5435375f98Sopenharmony_ci
5535375f98Sopenharmony_civoid testNotEqualMemory2(void)
5635375f98Sopenharmony_ci{
5735375f98Sopenharmony_ci    EXPECT_ABORT_BEGIN
5835375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY("fool", "food", 4);
5935375f98Sopenharmony_ci    VERIFY_FAILS_END
6035375f98Sopenharmony_ci}
6135375f98Sopenharmony_ci
6235375f98Sopenharmony_civoid testNotEqualMemory3(void)
6335375f98Sopenharmony_ci{
6435375f98Sopenharmony_ci    EXPECT_ABORT_BEGIN
6535375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(NULL, "food", 4);
6635375f98Sopenharmony_ci    VERIFY_FAILS_END
6735375f98Sopenharmony_ci}
6835375f98Sopenharmony_ci
6935375f98Sopenharmony_civoid testNotEqualMemory4(void)
7035375f98Sopenharmony_ci{
7135375f98Sopenharmony_ci    EXPECT_ABORT_BEGIN
7235375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY("fool", NULL, 4);
7335375f98Sopenharmony_ci    VERIFY_FAILS_END
7435375f98Sopenharmony_ci}
7535375f98Sopenharmony_ci
7635375f98Sopenharmony_civoid testNotEqualMemoryLengthZero(void)
7735375f98Sopenharmony_ci{
7835375f98Sopenharmony_ci    EXPECT_ABORT_BEGIN
7935375f98Sopenharmony_ci    TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 0);
8035375f98Sopenharmony_ci    VERIFY_FAILS_END
8135375f98Sopenharmony_ci}
82