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

102 lines
2.0 KiB
C++
Raw Normal View History

2021-08-15 13:35:40 -04:00
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2021-08-12
2023-01-21 08:28:43 -05:00
// PURPOSE: unit tests for the AGS02NA TVOC sensor
2021-08-15 13:35:40 -04:00
// https://github.com/RobTillaart/AGS02MA
// 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>
2021-09-24 06:31:48 -04:00
2021-08-15 13:35:40 -04:00
#include "Arduino.h"
#include "AGS02MA.h"
2021-09-24 06:31:48 -04:00
// writing to a virtual device does not work
// as millis() function is not implemented in
// the Arduino-CI environment
2021-08-15 13:35:40 -04:00
2023-01-21 08:28:43 -05:00
2021-08-15 13:35:40 -04:00
unittest_setup()
{
2022-08-12 06:15:08 -04:00
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", (char *) AGS02MA_LIB_VERSION);
2021-08-15 13:35:40 -04:00
}
2021-12-11 12:45:41 -05:00
2021-08-15 13:35:40 -04:00
unittest_teardown()
{
}
2021-12-11 12:45:41 -05:00
unittest(test_constants)
{
assertEqual( 0, AGS02MA_OK);
assertEqual(-10, AGS02MA_ERROR);
assertEqual(-11, AGS02MA_ERROR_CRC);
assertEqual(-12, AGS02MA_ERROR_READ);
2022-01-22 04:17:50 -05:00
assertEqual(-13, AGS02MA_ERROR_NOT_READY);
2021-12-11 12:45:41 -05:00
2022-08-12 06:15:08 -04:00
assertEqual(25000, AGS02MA_I2C_CLOCK);
2021-12-11 12:45:41 -05:00
}
2021-08-15 13:35:40 -04:00
unittest(test_base)
{
AGS02MA AGS(26);
Wire.begin();
2021-09-24 06:31:48 -04:00
2021-08-15 13:35:40 -04:00
assertTrue(AGS.begin());
assertTrue(AGS.isConnected()); // TODO - GODMODE
assertFalse(AGS.isHeated());
assertEqual(0, AGS.lastRead());
assertEqual(26, AGS.getAddress());
2021-09-24 06:31:48 -04:00
//assertTrue(AGS.setAddress(42));
//assertEqual(42, AGS.getAddress());
2021-08-15 13:35:40 -04:00
assertEqual(100000, AGS.getI2CResetSpeed());
AGS.setI2CResetSpeed(400000);
assertEqual(400000, AGS.getI2CResetSpeed());
assertEqual(0, AGS.lastError());
assertEqual(0, AGS.lastStatus());
}
unittest(test_mode)
{
AGS02MA AGS(26);
Wire.begin();
2021-09-24 06:31:48 -04:00
2021-08-15 13:35:40 -04:00
assertTrue(AGS.begin());
assertTrue(AGS.isConnected()); // TODO - GODMODE
assertEqual(255, AGS.getMode());
2021-09-24 06:31:48 -04:00
// assertTrue(AGS.setPPBMode());
// assertEqual(0, AGS.getMode());
2021-08-15 13:35:40 -04:00
2021-09-24 06:31:48 -04:00
// assertTrue(AGS.setUGM3Mode());
// assertEqual(1, AGS.getMode());
2021-08-15 13:35:40 -04:00
}
unittest_main()
2023-01-21 08:28:43 -05:00
// -- END OF FILE --