GY-63_MS5611/libraries/FastShiftOut/test/unit_test_001.cpp

98 lines
1.8 KiB
C++
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2020-12-03
// PURPOSE: unit tests for the FastShiftIn library
// https://github.com/RobTillaart/FastShiftIn
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
//
// supported assertions
// https://github.com/Arduino-CI/arduino_ci/blob/master/cpp/unittest/Assertion.h#L33-L42
// ----------------------------
// assertEqual(expected, actual)
// assertNotEqual(expected, actual)
// assertLess(expected, actual)
// assertMore(expected, actual)
// assertLessOrEqual(expected, actual)
// assertMoreOrEqual(expected, actual)
// assertTrue(actual)
// assertFalse(actual)
// assertNull(actual)
// assertNotNull(actual)
2021-05-28 07:26:27 -04:00
2021-01-29 06:31:58 -05:00
#include <ArduinoUnitTests.h>
#include "Arduino.h"
#include "FastShiftOut.h"
2021-05-28 07:26:27 -04:00
2021-01-29 06:31:58 -05:00
unittest_setup()
{
2021-12-17 09:24:28 -05:00
fprintf(stderr, "FASTSHIFTOUT_LIB_VERSION: %s\n", (char *) FASTSHIFTOUT_LIB_VERSION);
2021-01-29 06:31:58 -05:00
}
2021-05-28 07:26:27 -04:00
2021-01-29 06:31:58 -05:00
unittest_teardown()
{
}
unittest(test_constructor)
{
FastShiftOut FSO(12, 13);
assertEqual(LSBFIRST, FSO.getBitOrder());
FSO.setBitOrder(MSBFIRST);
assertEqual(MSBFIRST, FSO.getBitOrder());
}
unittest(test_constructor_LSB)
{
FastShiftOut FSO(12, 13, LSBFIRST);
assertEqual(LSBFIRST, FSO.getBitOrder());
FSO.setBitOrder(MSBFIRST);
assertEqual(MSBFIRST, FSO.getBitOrder());
}
unittest(test_constructor_MSB)
{
FastShiftOut FSO(12, 13, MSBFIRST);
assertEqual(MSBFIRST, FSO.getBitOrder());
FSO.setBitOrder(LSBFIRST);
assertEqual(LSBFIRST, FSO.getBitOrder());
}
unittest(test_write)
{
FastShiftOut FSO(12, 13);
assertEqual(1, FSO.write(0x42));
assertEqual(1, FSO.writeLSBFIRST(0xAA));
assertEqual(1, FSO.writeMSBFIRST(0x55));
}
unittest(test_print)
{
FastShiftOut FSO(12, 13);
assertEqual(5, FSO.print(FASTSHIFTOUT_LIB_VERSION));
assertEqual(7, FSO.println(FASTSHIFTOUT_LIB_VERSION));
}
unittest_main()
// --------