Exemplo n.º 1
0
void UnityTestRunner(unityfunction * setup,
        unityTestfunction * body,
        unityTestfunction * teardown,
        const char * printableName,
        const char * group,
        const char * name,
        const char * file, int line, struct _Unity * const unity_p)
{
    if (testSelected(name, unity_p) && groupSelected(group, unity_p))
    {
        unity_p->CurrentTestFailed = 0;
        unity_p->TestFile = file;
        unity_p->CurrentTestName = printableName;
        unity_p->CurrentTestLineNumber = line;
        if (!unity_p->Verbose)
            UNITY_OUTPUT_CHAR('.');
        else
            UnityPrint(printableName, unity_p);

        unity_p->NumberOfTests++;
#if defined(UNITY_DYNAMIC_MEM_DEBUG)
        UnityMalloc_StartTest();
#endif
#if defined(UNITY_CPP_UNIT_COMPAT)
        UnityPointer_Init(unity_p);
#endif 
        runTestCase(unity_p);
        /* remember setup has failed - skip teardown if so*/
        bool hasSetupFailed = false;
        if (TEST_PROTECT())
        {
            setup(unity_p);
            /*DX_PATCH for jumpless version. If setup failed don't perform the test*/
            if (!unity_p->CurrentTestFailed) 
            {
                body(unity_p->testLocalStorage, unity_p);
            }
            else
            {
                hasSetupFailed  = true;
            }
        }
        if (TEST_PROTECT() && !hasSetupFailed )
        {
            teardown(unity_p->testLocalStorage, unity_p);
        }
        if (TEST_PROTECT())
        {
#if defined(UNITY_CPP_UNIT_COMPAT)
            UnityPointer_UndoAllSets(unity_p);
#endif
#if defined(UNITY_DYNAMIC_MEM_DEBUG)
            if (!unity_p->CurrentTestFailed)
                UnityMalloc_EndTest(unity_p);
#endif
        }
        UnityConcludeFixtureTest(unity_p);
    }
}
Exemplo n.º 2
0
TEST(UnityFixture, PointerSetting)
{
    TEST_ASSERT_POINTERS_EQUAL(pointer1, 0);
    UT_PTR_SET(pointer1, &int1);
    UT_PTR_SET(pointer2, &int2);
    UT_PTR_SET(pointer3, &int3);
    TEST_ASSERT_POINTERS_EQUAL(pointer1, &int1);
    TEST_ASSERT_POINTERS_EQUAL(pointer2, &int2);
    TEST_ASSERT_POINTERS_EQUAL(pointer3, &int3);
    UT_PTR_SET(pointer1, &int4);
    UnityPointer_UndoAllSets();
    TEST_ASSERT_POINTERS_EQUAL(pointer1, 0);
    TEST_ASSERT_POINTERS_EQUAL(pointer2, (int*)2);
    TEST_ASSERT_POINTERS_EQUAL(pointer3, (int*)3);
}
Exemplo n.º 3
0
void UnityTestRunner(unityfunction* setup,
                     unityfunction* testBody,
                     unityfunction* teardown,
                     const char* printableName,
                     const char* group,
                     const char* name,
                     const char* file,
                     unsigned int line)
{
    if (testSelected(name) && groupSelected(group))
    {
        Unity.TestFile = file;
        Unity.CurrentTestName = printableName;
        Unity.CurrentTestLineNumber = line;
        if (!UnityFixture.Verbose)
            UNITY_OUTPUT_CHAR('.');
        else
        {
            UnityPrint(printableName);
        #ifndef UNITY_REPEAT_TEST_NAME
            Unity.CurrentTestName = NULL;
        #endif
        }

        Unity.NumberOfTests++;
        UnityMalloc_StartTest();
        UnityPointer_Init();

        UNITY_EXEC_TIME_START();

        if (TEST_PROTECT())
        {
            setup();
            testBody();
        }
        if (TEST_PROTECT())
        {
            teardown();
        }
        if (TEST_PROTECT())
        {
            UnityPointer_UndoAllSets();
            if (!Unity.CurrentTestFailed)
                UnityMalloc_EndTest();
        }
        UnityConcludeFixtureTest();
    }
}
Exemplo n.º 4
0
void UnityTestRunner(unityfunction* setup,
        unityfunction* testBody,
        unityfunction* teardown,
        const char * printableName,
        const char * group,
        const char * name,
        const char * file, int line)
{
    if (testSelected(name) && groupSelected(group))
    {
        Unity.CurrentTestFailed = 0;
        Unity.TestFile = file;
        Unity.CurrentTestName = printableName;
        Unity.CurrentTestLineNumber = line;
        if (!UnityFixture.Verbose)
            UNITY_OUTPUT_CHAR('.');
        else
            UnityPrint(printableName);

        Unity.NumberOfTests++;
        UnityMalloc_StartTest();
        UnityPointer_Init();

        runTestCase();
        if (TEST_PROTECT())
        {
            setup();
            testBody();
        }
        if (TEST_PROTECT())
        {
            teardown();
        }
        if (TEST_PROTECT())
        {
            UnityPointer_UndoAllSets();
            if (!Unity.CurrentTestFailed)
                UnityMalloc_EndTest();
            UnityConcludeFixtureTest();
        }
        else
        {
            //aborting - jwg - di i need these for the other TEST_PROTECTS?
        }
    }
}
Exemplo n.º 5
0
TEST(UnityFixture, PointerSet)
{
    char c1;
    char c2;
    char newC1;
    char newC2;
    p1 = &c1;
    p2 = &c2;

    UnityPointer_Init();
    UT_PTR_SET(p1, &newC1);
    UT_PTR_SET(p2, &newC2);
    TEST_ASSERT_POINTERS_EQUAL(&newC1, p1);
    TEST_ASSERT_POINTERS_EQUAL(&newC2, p2);
    UnityPointer_UndoAllSets();
    TEST_ASSERT_POINTERS_EQUAL(&c1, p1);
    TEST_ASSERT_POINTERS_EQUAL(&c2, p2);
}