Updated ADC test, now passing.
This commit is contained in:
parent
c731aae201
commit
5178c69a14
1 changed files with 18 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Author: Jake G
|
* Author: Jake G
|
||||||
* Date: 2024
|
* Date: 2025
|
||||||
* filename: test_ADC.c
|
* filename: test_ADC.c
|
||||||
* description: module_purpose
|
* description: module_purpose
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,15 +15,17 @@ extern "C"
|
||||||
#include "ch32v003hw.h"
|
#include "ch32v003hw.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_GROUP(test_ADC){
|
TEST_GROUP(test_ADC)
|
||||||
|
{
|
||||||
void setup(){
|
void setup(){
|
||||||
|
|
||||||
} void teardown(){
|
}
|
||||||
|
void teardown()
|
||||||
|
{
|
||||||
mock().checkExpectations();
|
mock().checkExpectations();
|
||||||
mock().clear();
|
mock().clear();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
;
|
|
||||||
|
|
||||||
TEST(test_ADC, FirstTest)
|
TEST(test_ADC, FirstTest)
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +35,7 @@ TEST(test_ADC, FirstTest)
|
||||||
TEST(test_ADC, ADC_PowerOnTest)
|
TEST(test_ADC, ADC_PowerOnTest)
|
||||||
{
|
{
|
||||||
// The ADCON bit should be high in the ADC_CTRL2 register.
|
// The ADCON bit should be high in the ADC_CTRL2 register.
|
||||||
mock().expectOneCall("RegEdit_SetBit").withPointerParameter("reg", (void *)&ADC1->CTLR2).withUnsignedIntParameter("bit_num", ADC_ADON);
|
mock().expectOneCall("RegEdit_u32_SetBit").withPointerParameter("reg", (void *)&ADC1->CTLR2).withUnsignedIntParameter("bit_num", ADC_ADON);
|
||||||
|
|
||||||
ADC_PowerOn();
|
ADC_PowerOn();
|
||||||
}
|
}
|
||||||
|
|
@ -195,18 +197,19 @@ static uint16_t ADC_ReadValueFake(uint8_t pin_num)
|
||||||
return 512;
|
return 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_GROUP(test_ADCRead){
|
TEST_GROUP(tg_ADCRead){
|
||||||
void setup(){
|
void setup(){
|
||||||
UT_PTR_SET(ADC_ReadValue, ADC_ReadValueFake);
|
UT_PTR_SET(ADC_ReadValue, ADC_ReadValueFake);
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown()
|
void teardown()
|
||||||
{
|
{
|
||||||
|
mock().checkExpectations();
|
||||||
|
mock().clear();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
;
|
|
||||||
|
|
||||||
TEST(test_ADCRead, FunctionPointerSwapWorks)
|
TEST(tg_ADCRead, FunctionPointerSwapWorks)
|
||||||
{
|
{
|
||||||
uint16_t value = ADC_ReadValue(0);
|
uint16_t value = ADC_ReadValue(0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue