adding repetitive DigIo mock test
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
#include "../libopeninv/include/params.h"
|
||||
#ifdef TEST_COMMON_H
|
||||
#include "../test/digio_mock.h"
|
||||
#endif
|
||||
|
||||
static bool IsEvseInput();
|
||||
static void DisableAll();
|
||||
@@ -13,3 +16,16 @@ static bool CheckUnplugged()
|
||||
{
|
||||
return IsEvseInput() && !Param::GetBool(Param::proximity);
|
||||
}
|
||||
|
||||
static void DisableAll()
|
||||
{
|
||||
DigIo::hvena_out.Clear();
|
||||
DigIo::acpres_out.Clear();
|
||||
DigIo::evseact_out.Clear();
|
||||
DigIo::ch1act_out.Clear();
|
||||
DigIo::ch2act_out.Clear();
|
||||
DigIo::ch2act_out.Clear();
|
||||
DigIo::ch1ena_out.Clear();
|
||||
DigIo::ch2ena_out.Clear();
|
||||
DigIo::ch3ena_out.Clear();
|
||||
}
|
||||
|
||||
@@ -120,18 +120,6 @@ static void EvseRead()
|
||||
}
|
||||
}
|
||||
|
||||
static void DisableAll()
|
||||
{
|
||||
DigIo::hvena_out.Clear();
|
||||
DigIo::acpres_out.Clear();
|
||||
DigIo::evseact_out.Clear();
|
||||
DigIo::ch1act_out.Clear();
|
||||
DigIo::ch2act_out.Clear();
|
||||
DigIo::ch2act_out.Clear();
|
||||
DigIo::ch1ena_out.Clear();
|
||||
DigIo::ch2ena_out.Clear();
|
||||
DigIo::ch3ena_out.Clear();
|
||||
}
|
||||
|
||||
|
||||
static bool CheckStartCondition()
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="TeslaGen2Charger" />
|
||||
<Option makefile_is_custom="1" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="armelfgcc" />
|
||||
<MakeCommands>
|
||||
<Build command="make" />
|
||||
<CompileFile command="$make -f $makefile $file" />
|
||||
<Clean command="$make -f $makefile clean" />
|
||||
<DistClean command="$make -f $makefile distclean$target" />
|
||||
<AskRebuildNeeded command="$make -q -f $makefile $target" />
|
||||
<SilentBuild command="$make -s -f $makefile $target" />
|
||||
</MakeCommands>
|
||||
<Build>
|
||||
<Target title="Release">
|
||||
<Option output="stm32_charger" prefix_auto="0" extension_auto="0" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="armelfgcc" />
|
||||
<Compiler>
|
||||
<Add directory="include" />
|
||||
</Compiler>
|
||||
<MakeCommands>
|
||||
<Build command="make" />
|
||||
<CompileFile command="$make -f $file " />
|
||||
<Clean command="make clean " />
|
||||
<DistClean command="$make -f $makefile distclean$target" />
|
||||
<AskRebuildNeeded command="$make -q" />
|
||||
<SilentBuild command="make > $(CMD_NULL)" />
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
</Build>
|
||||
<Unit filename="Makefile" />
|
||||
<Unit filename="include/anain_prj.h" />
|
||||
<Unit filename="include/chargercan.h" />
|
||||
<Unit filename="include/digio_prj.h" />
|
||||
<Unit filename="include/errormessage_prj.h" />
|
||||
<Unit filename="include/hwdefs.h" />
|
||||
<Unit filename="include/hwinit.h" />
|
||||
<Unit filename="include/param_prj.h" />
|
||||
<Unit filename="libopeninv/include/anain.h" />
|
||||
<Unit filename="libopeninv/include/digio.h" />
|
||||
<Unit filename="libopeninv/include/errormessage.h" />
|
||||
<Unit filename="libopeninv/include/foc.h" />
|
||||
<Unit filename="libopeninv/include/fu.h" />
|
||||
<Unit filename="libopeninv/include/my_fp.h" />
|
||||
<Unit filename="libopeninv/include/my_math.h" />
|
||||
<Unit filename="libopeninv/include/my_string.h" />
|
||||
<Unit filename="libopeninv/include/param_save.h" />
|
||||
<Unit filename="libopeninv/include/params.h" />
|
||||
<Unit filename="libopeninv/include/picontroller.h" />
|
||||
<Unit filename="libopeninv/include/printf.h" />
|
||||
<Unit filename="libopeninv/include/sine_core.h" />
|
||||
<Unit filename="libopeninv/include/stm32_can.h" />
|
||||
<Unit filename="libopeninv/include/stm32_loader.h" />
|
||||
<Unit filename="libopeninv/include/stm32scheduler.h" />
|
||||
<Unit filename="libopeninv/include/terminal.h" />
|
||||
<Unit filename="libopeninv/include/terminalcommands.h" />
|
||||
<Unit filename="libopeninv/src/anain.cpp" />
|
||||
<Unit filename="libopeninv/src/digio.cpp" />
|
||||
<Unit filename="libopeninv/src/errormessage.cpp" />
|
||||
<Unit filename="libopeninv/src/foc.cpp" />
|
||||
<Unit filename="libopeninv/src/fu.cpp" />
|
||||
<Unit filename="libopeninv/src/my_fp.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="libopeninv/src/my_string.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="libopeninv/src/param_save.cpp" />
|
||||
<Unit filename="libopeninv/src/params.cpp" />
|
||||
<Unit filename="libopeninv/src/picontroller.cpp" />
|
||||
<Unit filename="libopeninv/src/printf.cpp" />
|
||||
<Unit filename="libopeninv/src/sine_core.cpp" />
|
||||
<Unit filename="libopeninv/src/stm32_can.cpp" />
|
||||
<Unit filename="libopeninv/src/stm32scheduler.cpp" />
|
||||
<Unit filename="libopeninv/src/terminal.cpp" />
|
||||
<Unit filename="libopeninv/src/terminalcommands.cpp" />
|
||||
<Unit filename="linker.ld" />
|
||||
<Unit filename="src/chargercan.cpp" />
|
||||
<Unit filename="src/hwinit.cpp" />
|
||||
<Unit filename="src/main.cpp" />
|
||||
<Unit filename="src/terminal_prj.cpp" />
|
||||
<Extensions>
|
||||
<DoxyBlocks>
|
||||
<comment_style block="0" line="0" />
|
||||
<doxyfile_project />
|
||||
<doxyfile_build />
|
||||
<doxyfile_warnings />
|
||||
<doxyfile_output />
|
||||
<doxyfile_dot class_diagrams="1" have_dot="1" />
|
||||
<general />
|
||||
</DoxyBlocks>
|
||||
<debugger>
|
||||
<remote_debugging>
|
||||
<options conn_type="0" ip_address="localhost" ip_port="3333" additional_cmds="load
r" />
|
||||
</remote_debugging>
|
||||
<remote_debugging target="Release">
|
||||
<options conn_type="0" ip_address="localhost" ip_port="3333" additional_cmds="load
r" />
|
||||
</remote_debugging>
|
||||
</debugger>
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../libopeninv/include/params.h"
|
||||
#include "test.h"
|
||||
#include "test_can.h"
|
||||
#include "test_io.h"
|
||||
#include "test_state.h"
|
||||
|
||||
extern void Param::Change(Param::PARAM_NUM ParamNum){ };
|
||||
@@ -16,6 +17,7 @@ int main() {
|
||||
TestCase tests[] = {
|
||||
(TestCase){"test_is_evse_input", test_is_evse_input},
|
||||
(TestCase){"test_check_unplugged", test_check_unplugged},
|
||||
(TestCase){"test_disable_all", test_disable_all},
|
||||
// Example:
|
||||
//(TestCase){"Your tests name", function_name_without_brackets}
|
||||
//...
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
|
||||
#ifndef TEST_COMMON_H
|
||||
#define TEST_COMMON_H
|
||||
#include "functions.h"
|
||||
#include "digio_mock.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef TEST_IO_H
|
||||
#define TEST_IO_H
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include "test_common.h"
|
||||
|
||||
void test_disable_all()
|
||||
{
|
||||
DigIo::hvena_out.Set();
|
||||
DigIo::acpres_out.Set();
|
||||
DigIo::evseact_out.Set();
|
||||
DigIo::ch1act_out.Set();
|
||||
DigIo::ch2act_out.Set();
|
||||
DigIo::ch2act_out.Set();
|
||||
DigIo::ch1ena_out.Set();
|
||||
DigIo::ch2ena_out.Set();
|
||||
DigIo::ch3ena_out.Set();
|
||||
|
||||
assert(DigIo::hvena_out.Get());
|
||||
assert(DigIo::hvena_out.Get());
|
||||
assert(DigIo::acpres_out.Get());
|
||||
assert(DigIo::evseact_out.Get());
|
||||
assert(DigIo::ch1act_out.Get());
|
||||
assert(DigIo::ch2act_out.Get());
|
||||
assert(DigIo::ch2act_out.Get());
|
||||
assert(DigIo::ch1ena_out.Get());
|
||||
assert(DigIo::ch2ena_out.Get());
|
||||
assert(DigIo::ch3ena_out.Get());
|
||||
|
||||
DisableAll();
|
||||
|
||||
assert(!DigIo::hvena_out.Get());
|
||||
assert(!DigIo::hvena_out.Get());
|
||||
assert(!DigIo::acpres_out.Get());
|
||||
assert(!DigIo::evseact_out.Get());
|
||||
assert(!DigIo::ch1act_out.Get());
|
||||
assert(!DigIo::ch2act_out.Get());
|
||||
assert(!DigIo::ch2act_out.Get());
|
||||
assert(!DigIo::ch1ena_out.Get());
|
||||
assert(!DigIo::ch2ena_out.Get());
|
||||
assert(!DigIo::ch3ena_out.Get());
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include "test_common.h"
|
||||
#include "functions.h"
|
||||
|
||||
void test_is_evse_input()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user