Sha256: 13f9bee19932589e52df4b86dcc197f1ada6e64ce42c27f76f34bc251de0a34c

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

extern "C"
{
#include "driver.h"
#include "registers.h"
}
#include "../../fff.h"
#include <gtest/gtest.h>


extern "C"
{
    static uint8_t readVal;
    static int readCalled;
    static uint32_t readRegister;
    uint8_t IO_MEM_RD8(uint32_t reg)
    {
        readRegister = reg;
        readCalled++;
        return readVal;
    }

    static uint32_t writeRegister;
    static uint8_t writeVal;
    static int writeCalled;
    void IO_MEM_WR8(uint32_t reg, uint8_t val)
    {
        writeRegister = reg;
        writeVal = val;
        writeCalled++;
    }
}

TEST(Driver, When_writing_Then_writes_data_to_DRIVER_OUTPUT_REGISTER)
{
    driver_write(0x34);
    ASSERT_EQ(1u, writeCalled);
    ASSERT_EQ(0x34u, writeVal);
    ASSERT_EQ(DRIVER_OUTPUT_REGISTER, writeRegister);
}


TEST(Driver, When_reading_data_Then_reads_from_DRIVER_INPUT_REGISTER)
{
    readVal = 0x55;
    uint8_t returnedValue = driver_read();
    ASSERT_EQ(1u, readCalled);
    ASSERT_EQ(0x55u, returnedValue);
    ASSERT_EQ(readRegister, DRIVER_INPUT_REGISTER);
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ceedling-0.28.1 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp
ceedling-0.27.0 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp
ceedling-0.25.0 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp
ceedling-0.24.0 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp
ceedling-0.22.0 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp
ceedling-0.21.0 plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp