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

93 lines
1.9 KiB
C++
Raw Normal View History

2021-05-26 06:02:17 -04:00
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2021-04-30
// PURPOSE: unit tests for I2C digital PotentioMeter AD5144A
// https://github.com/RobTillaart/AD5144A
// 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 "AD5144A.h"
unittest_setup()
{
2022-10-25 14:56:18 -04:00
fprintf(stderr, "AD51XXA_VERSION: %s\n", (char *) AD51XXA_VERSION);
2021-05-26 06:02:17 -04:00
}
unittest_teardown()
{
}
unittest(test_constructors)
{
Wire.begin();
2021-12-11 09:52:48 -05:00
AD5123 AD23(0x2C);
assertEqual( 4, AD23.pmCount());
assertEqual(127, AD23.maxValue());
2022-10-25 14:56:18 -04:00
// assertEqual(0, AD23.read()) // todo
2021-12-11 09:52:48 -05:00
AD5124 AD24(0x2C);
assertEqual( 4, AD24.pmCount());
assertEqual(127, AD24.maxValue());
AD5143 AD43(0x2C);
assertEqual( 4, AD43.pmCount());
assertEqual(255, AD43.maxValue());
AD5144A AD44(0x2C);
assertEqual( 4, AD44.pmCount());
assertEqual(255, AD44.maxValue());
AD5144A AD44A(0x2C);
assertEqual( 4, AD44A.pmCount());
assertEqual(255, AD44A.maxValue());
AD5122A AD22A(0x2C);
assertEqual( 2, AD22A.pmCount());
assertEqual(127, AD22A.maxValue());
AD5142A AD42A(0x2C);
assertEqual( 2, AD42A.pmCount());
assertEqual(255, AD42A.maxValue());
AD5121 AD21(0x2C);
assertEqual( 1, AD21.pmCount());
assertEqual(127, AD21.maxValue());
AD5141 AD41(0x2C);
assertEqual( 1, AD41.pmCount());
assertEqual(255, AD41.maxValue());
}
unittest(test_constants)
{
assertEqual( 0, AD51XXA_OK);
assertEqual(100, AD51XXA_ERROR);
assertEqual(101, AD51XXA_INVALID_POT);
assertEqual(102, AD51XXA_INVALID_VALUE);
2021-05-26 06:02:17 -04:00
}
unittest_main()
// --------