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

86 lines
1.4 KiB
C++
Raw Normal View History

2022-08-03 05:00:56 -04:00
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
2022-10-25 15:41:23 -04:00
// DATE: 2022-07-31
// PURPOSE: unit tests for I2C digital PotentioMeter AD5245
// https://github.com/RobTillaart/AD5245
2022-08-03 05:00:56 -04:00
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
//
// supported assertions
// ----------------------------
// assertEqual(expected, actual)
// assertNotEqual(expected, actual)
// assertLess(expected, actual)
// assertMore(expected, actual)
// assertLessOrEqual(expected, actual)
// assertMoreOrEqual(expected, actual)
// assertTrue(actual)
// assertFalse(actual)
// assertNull(actual)
#include <ArduinoUnitTests.h>
#include "AD5245.h"
unittest_setup()
{
fprintf(stderr, "\nAD5245_LIB_VERSION %s\n", (char*) AD5245_LIB_VERSION);
}
unittest_teardown()
{
}
2022-10-25 15:41:23 -04:00
2022-08-03 05:00:56 -04:00
unittest(test_constants)
{
assertEqual(000, AD5245_OK);
assertEqual(100, AD5245_ERROR);
2023-01-16 08:38:52 -05:00
assertEqual(128, AD5245_MIDPOINT);
2022-08-03 05:00:56 -04:00
}
unittest(test_constructors)
{
Wire.begin();
AD5245 AD(0x2C);
AD.begin();
assertEqual(128, AD.read());
}
unittest(test_reset)
{
Wire.begin();
AD5245 AD(0x2C);
assertEqual(128, AD.read());
AD.write(0);
assertEqual(0, AD.read());
AD.reset();
assertEqual(128, AD.read());
}
unittest(test_write_read)
{
Wire.begin();
AD5245 AD(0x2C);
assertEqual(128, AD.read());
AD.write(42);
assertEqual(42, AD.read());
}
unittest_main()
// --------