Sha256: a729aa409f5bd836341e9d521b13cfd9475c3929be6dd22202c0712f27f1a4ed

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 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 "UsartModel.h"
#include "ModelConfig.h"
#include "MockTemperatureFilter.h"
#include "MockUsartBaudRateRegisterCalculator.h"
#include <math.h>

void setUp(void)
{
}

void tearDown(void)
{
}

void testGetBaudRateRegisterSettingShouldReturnAppropriateBaudRateRegisterSetting(void)
{
  uint8 dummyRegisterSetting = 17;
  UsartModel_CalculateBaudRateRegisterSetting_ExpectAndReturn(MASTER_CLOCK, USART0_BAUDRATE, dummyRegisterSetting);

  TEST_ASSERT_EQUAL_UINT8(dummyRegisterSetting, UsartModel_GetBaudRateRegisterSetting());
}

void testGetFormattedTemperatureFormatsTemperatureFromCalculatorAppropriately(void)
{
  TemperatureFilter_GetTemperatureInCelcius_ExpectAndReturn(25.0f);
  TEST_ASSERT_EQUAL_STRING("25.0 C\n", UsartModel_GetFormattedTemperature());
}

void testShouldReturnErrorMessageUponInvalidTemperatureValue(void)
{
  TemperatureFilter_GetTemperatureInCelcius_ExpectAndReturn(-INFINITY);
  TEST_ASSERT_EQUAL_STRING("Temperature sensor failure!\n", UsartModel_GetFormattedTemperature());
}

void testShouldReturnWakeupMessage(void)
{
  TEST_ASSERT_EQUAL_STRING("It's Awesome Time!\n", UsartModel_GetWakeupMessage());
}

Version data entries

2 entries across 2 versions & 1 rubygems

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