//***************************************************************************** // (C) Automotive Lighting Reutlingen GmbH // Tuebinger Strasse 123, 72762 Reutlingen, Germany // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting Reutlingen GmbH. //***************************************************************************** //----------------------------------------------------------------------------- /// \file Test.c /// /// \brief Unit Test Cases for software component module CddBoost /// /// \author /// mailTo: //----------------------------------------------------------------------------- #include #include #include #include #include //============================================================================= // Stub function declarations //============================================================================= void CddNcv78702_Init(void) {} void CddNcv78702_Shutdown(void) {} void CddNcv78702_SetBoosterVoltage(const uint32 ulIdx, const uint16 unVBoostTarget_mV) { (void)ulIdx; (void)unVBoostTarget_mV; } //static void InitConditions(void) //{ // RestoreStubContents(); //} //============================================================================= // Function declarations (of the module itself) //============================================================================= extern void CddBoost_Init(void); extern void CddBoost_SetPara(tCddBoostPara* pPara); extern void CddBoost_Cycle20ms(void); extern void CddBoost_SetTarget(tCddBoostTarget* pTarget); extern void CddBoost_GetStatus(tCddBoostStatus* pStatus); extern void CddBoost_Shutdown(void); //============================================================================= // Function parameter stubs (of the module ifself) //============================================================================= tCddBoostPara CddBoost_SetPara_Param1; tCddBoostTarget CddBoost_SetTarget_Param1; tCddBoostStatus CddBoost_GetStatus_Param1; //============================================================================= // Global variables (of the module itself) //============================================================================= extern tCddBoostTarget CddBoost_sTarget; //============================================================================= // Test Cases //============================================================================= //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_Init /// /// \Test Case Description /// - Test subject: /// Check write to data mirror /// /// - Test Design Technique: DT (Decision Table) /// /// - Preconditions: none /// /// - Expected test results: /// - High byte of data mirror must be different from 0 /// //----------------------------------------------------------------------------- void Mt_CddBoost_Init(void) { //Step 1) Set pre - conditions // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT //Step 3) Call the FUT CddBoost_Init(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(0u, 0u, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_SetPara /// /// \Test Case Description /// - Test subject: /// Check if empty function is called (coverage only) /// /// - Test Design Technique: DT (Decision Table) /// /// - Preconditions: none /// /// - Expected test results: /// - none /// //----------------------------------------------------------------------------- void Mt_CddBoost_SetPara(void) { //Step 1) Set pre - conditions // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT CddBoost_SetPara_Param1 = (tCddBoostPara){ .unPara1 = 0u, .unPara2 = 0u }; //Step 3) Call the FUT CddBoost_SetPara(&CddBoost_SetPara_Param1); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value // none: coverage only } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_Cycle20ms /// /// \Test Case Description /// - Test subject: /// Check if empty function is called (coverage only) /// /// - Test Design Technique: DT (Decision Table) /// /// - Preconditions: none /// /// - Expected test results: /// - none /// //----------------------------------------------------------------------------- void Mt_CddBoost_Cycle20ms(void) { //Step 1) Set pre - conditions // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT //Step 3) Call the FUT CddBoost_Cycle20ms(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value // none: coverage only } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_SetTarget /// /// \Test Case Description /// - Test subject: /// Set a new value for boost voltage /// /// - Test Design Technique: DT (Decision Table) /// /// - Preconditions: none /// /// - Expected test results: /// - Boost Voltage is updated /// //----------------------------------------------------------------------------- void Mt_CddBoost_SetTarget(void) { //Step 1) Set pre - conditions // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT CddBoost_SetTarget_Param1.aunBoostVolt_mV[0] = 47000u; CddBoost_SetTarget_Param1.ucCrc = 0u; //Step 3) Call the FUT CddBoost_SetTarget(&CddBoost_SetTarget_Param1); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddBoost_sTarget.aunBoostVolt_mV[0], 47000u, ==); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_GetStatus /// /// \Test Case Description /// - Test subject: /// Check Boost status /// /// - Test Design Technique: DT (Decision Table) /// /// - Preconditions: none /// /// - Expected test results: /// -Read Boost status /// //----------------------------------------------------------------------------- void Mt_CddBoost_GetStatus(void) { //Step 1) Set pre - conditions // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT CddBoost_GetStatus_Param1.aStatus[0] = eCddBoost_NoSupport; CddBoost_GetStatus_Param1.ucCrc = 0u; //Step 3) Call the FUT CddBoost_GetStatus(&CddBoost_GetStatus_Param1); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddBoost_GetStatus_Param1.aStatus[0], eCddBoost_StatusOk, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddBoost_Shutdown /// /// \Test methods: /// - Requirements-based test /// /// \Test Case Description /// - Test subject: /// test needed for coverage /// /// - Test Design Technique: ET (Exploratory Test) /// /// - Preconditions: /// - N/A /// //----------------------------------------------------------------------------- void Mt_CddBoost_Shutdown(void) { //Unit test just for coverage. //Step x: call FUT CddBoost_Shutdown(); } void ALUnitTest_AddTests(void) { // CddBoost.c tests ALUnitTest_AddFunction("Mt_CddBoost_Init", Mt_CddBoost_Init); ALUnitTest_AddFunction("Mt_CddBoost_SetPara", Mt_CddBoost_SetPara); ALUnitTest_AddFunction("Mt_CddBoost_Cycle20ms", Mt_CddBoost_Cycle20ms); ALUnitTest_AddFunction("Mt_CddBoost_SetTarget", Mt_CddBoost_SetTarget); ALUnitTest_AddFunction("Mt_CddBoost_GetStatus", Mt_CddBoost_GetStatus); ALUnitTest_AddFunction("Mt_CddBoost_Shutdown", Mt_CddBoost_Shutdown); // project specific tests of adapter ALUnitTest_AddTests_Adapter(); }