//***************************************************************************** // (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 CddBooster /// /// \author /// mailTo: //----------------------------------------------------------------------------- #ifndef UNIT_TEST #else #ifndef RTE_ALLOW_CROSS_HEADER_INCLUSION #define RTE_ALLOW_CROSS_HEADER_INCLUSION #endif #endif #include #include #include #include #include //#include // variables for use in test uint8* Test_Crc_DataPtr = (uint8*)0u; uint32 Test_Crc_Length = 0u; uint32 Test_Crc_StartValue32 = 0u; boolean Test_Crc_IsFirstCall = FALSE; uint32 Test_Crc = 0u; // stub functions Std_ReturnType Rte_Write_ctadCddEft_ppaseCddEftCrcStatus0_eEftDataStatus(tieDataStatus Data) { return RTE_E_OK; } Std_ReturnType Rte_Call_ctadCddEft_ppaclCodMStartCodingDataVerification_StartCodingDataVerification(void) { return RTE_E_OK; } uint32 Crc_CalculateCRC32(uint8* Crc_DataPtr, uint32 Crc_Length, uint32 Crc_StartValue32, boolean Crc_IsFirstCall) { Test_Crc_DataPtr = Crc_DataPtr; Test_Crc_Length = Crc_Length; Test_Crc_StartValue32 = Crc_StartValue32; Test_Crc_IsFirstCall = Crc_IsFirstCall; return Test_Crc; } // STATIC_AL variables for use in test extern boolean CddEft_CrcValid; // functions for use in test extern void riCddEftInit (void); extern void rdCddEftDeInit (void); extern void CddEft_Init (void); extern boolean CddEft_DataValid(void); static void InitConditions(void) { //RestoreStubContents(); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddEft_Init /// /// \Test Case Description /// - Test subject: /// Check correct call of CRC function /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - Positive and negative CRC test /// //----------------------------------------------------------------------------- void Mt_CddEft_Init(void) { //Step 1) Set pre - conditions InitConditions(); // default initialization EftData.Eft_Calib.Val.Text.acText[0] = 'C'; EftData.Eft_Calib.Val.Text.acText[1] = 'A'; EftData.Eft_Calib.Val.Text.acText[2] = 'L'; EftData.Eft_Calib.Val.Text.acText[3] = 'I'; //Step 2) Assign all input values to the corresponding input variables identified in the FUT Test_Crc = 1u; //Step 3) Call the FUT CddEft_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(Test_Crc_Length, 0x2FCu, == ); AL_UNITTEST_CHECK(Test_Crc_StartValue32, 0xFFFFFFFFu, == ); AL_UNITTEST_CHECK(Test_Crc_IsFirstCall, TRUE, == ); AL_UNITTEST_CHECK(CddEft_CrcValid, FALSE, == ); //Step 2) Assign all input values to the corresponding input variables identified in the FUT Test_Crc = 0u; //Step 3) Call the FUT CddEft_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(CddEft_CrcValid, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_CddEft_DataValid /// /// \Test Case Description /// - Test subject: /// Check return value /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - data invalid /// //----------------------------------------------------------------------------- void Mt_CddEft_DataValid(void) { boolean boEftValid; //Step 1) Set pre - conditions InitConditions(); // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT //Step 3) Call the FUT boEftValid = CddEft_DataValid(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(boEftValid, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_riCddEftInit /// /// \Test Case Description /// - Test subject: /// Check for invalid conditions /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - CRC invalid /// //----------------------------------------------------------------------------- void Mt_riCddEftInit(void) { //Step 1) Set pre - conditions InitConditions(); // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT EftData.Eft_Calib.Val.Text.acText[0] = 'C'; // right EftData.Eft_Calib.Val.Text.acText[1] = 'a'; // wrong //Step 3) Call the FUT riCddEftInit(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddEft_CrcValid, TRUE, == ); //Step 2) Assign all input values to the corresponding input variables identified in the FUT EftData.Eft_Calib.Val.Text.acText[1] = 'A'; // right EftData.Eft_Calib.Val.Text.acText[2] = 'l'; // wrong //Step 3) Call the FUT riCddEftInit(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddEft_CrcValid, TRUE, == ); //Step 2) Assign all input values to the corresponding input variables identified in the FUT EftData.Eft_Calib.Val.Text.acText[2] = 'L'; // right EftData.Eft_Calib.Val.Text.acText[3] = 'i'; // wrong //Step 3) Call the FUT riCddEftInit(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddEft_CrcValid, TRUE, == ); //Step 2) Assign all input values to the corresponding input variables identified in the FUT EftData.Eft_Calib.Val.Text.acText[3] = 'c'; // wrong //Step 3) Call the FUT riCddEftInit(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value AL_UNITTEST_CHECK(CddEft_CrcValid, TRUE, == ); } //----------------------------------------------------------------------------- /// \Test Case : Mt_rdCddEftDeInit /// /// \Test Case Description /// - Test subject: /// n/a (empty function) /// /// - Test Design Technique: ET (Exploratory Testing) /// /// - Preconditions: none /// /// - Expected test results: /// - n/a (empty function) /// //----------------------------------------------------------------------------- void Mt_rdCddEftDeInit(void) { //Step 1) Set pre - conditions InitConditions(); // default initialization //Step 2) Assign all input values to the corresponding input variables identified in the FUT //Step 3) Call the FUT rdCddEftDeInit(); //Step 4) Check that the value of the output variables set/changed by the FUT matchs the corresponding expected output value // n/a (coverage only) } void ALUnitTest_AddTests(void) { ALUnitTest_AddFunction("Mt_CddEft_Init" , Mt_CddEft_Init); ALUnitTest_AddFunction("Mt_CddEft_DataValid", Mt_CddEft_DataValid); ALUnitTest_AddFunction("Mt_riCddEftInit" , Mt_riCddEftInit); ALUnitTest_AddFunction("Mt_rdCddEftDeInit" , Mt_rdCddEftDeInit); }