foxBMS - Unit Tests  1.1.2
The foxBMS Unit Tests API Documentation
test_bms.c File Reference

Tests for the bms driver implementation. More...

#include "unity.h"
#include "Mockbal.h"
#include "Mockbattery_system_cfg.h"
#include "Mockcontactor.h"
#include "Mockdatabase.h"
#include "Mockdiag.h"
#include "Mockfassert.h"
#include "Mockinterlock.h"
#include "Mockmeas.h"
#include "Mockmic.h"
#include "Mockos.h"
#include "Mockplausibility.h"
#include "Mocksoa.h"
#include "bms.h"
#include "foxmath.h"
#include "test_assert_helper.h"
Include dependency graph for test_bms.c:

Go to the source code of this file.

Macros

#define NUM_PRECHARGE_TESTS   13
 

Functions

void setUp (void)
 
void tearDown (void)
 
STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback (void *dataptrtoReceiver, int num_calls)
 
void testCheckPrechargeIterateStub (void)
 Iterate over a callback that supplies various scenarios and check if they work as expected. More...
 
void testBMS_GetCurrentFlowDirectionWithTypicalValues (void)
 
void testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin (void)
 
void testBMS_CheckPrechargeInvalidStringNumber (void)
 

Variables

DIAG_ID_CFG_s DIAG_ID_cfg [] = {}
 
DIAG_DEV_s diag_device
 
BS_STRING_PRECHARGE_PRESENT_e bs_stringsWithPrecharge [BS_NR_OF_STRINGS]
 
STD_RETURN_TYPE_e prechargeExpectedResults [BS_NR_OF_STRINGS][NUM_PRECHARGE_TESTS] = {0}
 

Detailed Description

Tests for the bms driver implementation.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-04-01 (date of creation)
Updated
2020-04-01 (date of last update)
Prefix
TEST

Definition in file test_bms.c.

Macro Definition Documentation

◆ NUM_PRECHARGE_TESTS

#define NUM_PRECHARGE_TESTS   13

Definition at line 95 of file test_bms.c.

Function Documentation

◆ MockDATA_ReadBlock_Callback()

STD_RETURN_TYPE_e MockDATA_ReadBlock_Callback ( void *  dataptrtoReceiver,
int  num_calls 
)

Definition at line 100 of file test_bms.c.

◆ setUp()

void setUp ( void  )

Definition at line 88 of file test_bms.c.

◆ tearDown()

void tearDown ( void  )

Definition at line 91 of file test_bms.c.

◆ testBMS_CheckPrechargeInvalidStringNumber()

void testBMS_CheckPrechargeInvalidStringNumber ( void  )

check that invalid values to BMS_CheckPrecharge trip an assertion

invalid values are all those that do not fall into 0 <= stringNumber < BS_NR_OF_STRINGS

Definition at line 313 of file test_bms.c.

Here is the call graph for this function:

◆ testBMS_GetCurrentFlowDirectionWithTypicalValues()

void testBMS_GetCurrentFlowDirectionWithTypicalValues ( void  )

Definition at line 246 of file test_bms.c.

Here is the call graph for this function:

◆ testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin()

void testCheckCurrentValueDirectionWithCurrentZeroMaxAndMin ( void  )

Definition at line 289 of file test_bms.c.

Here is the call graph for this function:

◆ testCheckPrechargeIterateStub()

void testCheckPrechargeIterateStub ( void  )

Iterate over a callback that supplies various scenarios and check if they work as expected.

This function uses the callback MockDATA_ReadBlock_Callback() in order to inject current tables and voltage tables into the returned database tables. The array prechargeExpectedResults contains prepared return values against which the output of TEST_BMS_CheckPrecharge() is compared.

Definition at line 229 of file test_bms.c.

Here is the call graph for this function:

Variable Documentation

◆ bs_stringsWithPrecharge

Initial value:

Precharge presence of not for each string

Definition at line 81 of file test_bms.c.

◆ diag_device

DIAG_DEV_s diag_device
Initial value:
= {
.nr_of_ch = sizeof(DIAG_ID_cfg) / sizeof(DIAG_ID_CFG_s),
.ch_cfg = &DIAG_ID_cfg[0],
.numberOfFatalErrors = 0u,
}
DIAG_ID_CFG_s DIAG_ID_cfg[]
Definition: test_bms.c:73

diag device configuration struct

Definition at line 75 of file test_bms.c.

◆ DIAG_ID_cfg

DIAG_ID_CFG_s DIAG_ID_cfg[] = {}

variable tracking the state of the diag channels

Definition at line 73 of file test_bms.c.

◆ prechargeExpectedResults

STD_RETURN_TYPE_e prechargeExpectedResults[BS_NR_OF_STRINGS][NUM_PRECHARGE_TESTS] = {0}

Definition at line 96 of file test_bms.c.