Subversion Repositories FuelGauge

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
#include "jtest.h"
2
#include "arr_desc.h"
3
#include "arm_math.h"
4
#include "type_abbrev.h"
5
#include "test_templates.h"
6
 
7
/* Bucket of zeros. For comparison with the output of arm_pid_reset_xxx. */
8
ARR_DESC_DEFINE(float32_t, zeroes, 3, CURLY(0));
9
 
10
/**
11
 *  Define a JTEST_TEST_t for the function arm_pid_reset_xxx function having
12
 *  suffix.
13
 */
14
#define ARM_PID_RESET_TEST(suffix)                                      \
15
    JTEST_DEFINE_TEST(arm_pid_reset_##suffix##_test,                    \
16
                      arm_pid_reset_##suffix)                           \
17
    {                                                                   \
18
        /* Initialise the pid_instance */                               \
19
        arm_pid_instance_##suffix pid_inst = { 0 };                     \
20
            pid_inst.state[0] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff;  \
21
            pid_inst.state[1] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff;  \
22
            pid_inst.state[2] = (TYPE_FROM_ABBREV(suffix)) 0xffffffff;  \
23
                                                                        \
24
            /* Display cycle count and run test */                      \
25
            JTEST_COUNT_CYCLES(arm_pid_reset_##suffix(&pid_inst));      \
26
                                                                        \
27
            /* Test correctness */                                      \
28
            TEST_ASSERT_BUFFERS_EQUAL(                                  \
29
                pid_inst.state,                                         \
30
                zeroes.data_ptr,                                        \
31
                3 * sizeof(TYPE_FROM_ABBREV(suffix)));                  \
32
                                                                        \
33
            return JTEST_TEST_PASSED;                                   \
34
    }
35
 
36
ARM_PID_RESET_TEST(f32);
37
ARM_PID_RESET_TEST(q31);
38
ARM_PID_RESET_TEST(q15);
39
 
40
/*--------------------------------------------------------------------------------*/
41
/* Collect all tests in a group */
42
/*--------------------------------------------------------------------------------*/
43
 
44
JTEST_DEFINE_GROUP(pid_reset_tests)
45
{
46
    /*
47
      To skip a test, comment it out.
48
    */
49
    JTEST_TEST_CALL(arm_pid_reset_f32_test);
50
    JTEST_TEST_CALL(arm_pid_reset_q31_test);
51
    JTEST_TEST_CALL(arm_pid_reset_q15_test);
52
}