Sha256: 57ff0dec996d5edcc941c1831164dc49a2a1ecdeef90cbbaa9e8a1fb07bde309

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

/* =========================================================================
    Ceedling - Test-Centered Build System for C
    ThrowTheSwitch.org
    Copyright (c) 2010-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
    SPDX-License-Identifier: MIT
========================================================================= */

#include "unity.h"
#include "Types.h"
#include "UsartConductor.h"
#include "UsartModel.h"
#include "UsartHardware.h"
#include "ModelConfig.h"
#include "MockTaskScheduler.h"
#include "MockUsartConfigurator.h"
#include "MockUsartPutChar.h"
#include "MockTemperatureFilter.h"
#include "MockUsartBaudRateRegisterCalculator.h"
#include <string.h>

/* NOTE: we probably wouldn't actually perform this test on our own projects
  but it's a good example of testing the same module(s) from multiple test
  files, and therefore we like having it in this example. 
*/

#ifndef TEST_USART_INTEGRATED_STRING
#define TEST_USART_INTEGRATED_STRING "THIS WILL FAIL"
#endif

void setUp(void)
{
}

void tearDown(void)
{
}

void testShouldInitializeHardwareWhenInitCalled(void)
{
  size_t i;
  const char* test_str = TEST_USART_INTEGRATED_STRING;

  UsartModel_CalculateBaudRateRegisterSetting_ExpectAndReturn(MASTER_CLOCK, USART0_BAUDRATE, 4);
  Usart_ConfigureUsartIO_Expect();
  Usart_EnablePeripheralClock_Expect();
  Usart_Reset_Expect();
  Usart_ConfigureMode_Expect();
  Usart_SetBaudRateRegister_Expect(4);
  Usart_Enable_Expect();
  for (i=0; i < strlen(test_str); i++)
  {
    Usart_PutChar_Expect(test_str[i]);
  }

  UsartConductor_Init();
}

void testRunShouldNotDoAnythingIfSchedulerSaysItIsNotTimeYet(void)
{
  TaskScheduler_DoUsart_ExpectAndReturn(FALSE);

  UsartConductor_Run();
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ceedling-1.0.1 examples/temp_sensor/test/TestUsartIntegrated.c
ceedling-1.0.0 examples/temp_sensor/test/TestUsartIntegrated.c