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

91 lines
1.8 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
// PURPOSE: unit tests for the AGS02NA tvoc sensor
// 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
unittest_setup()
{
}
unittest_teardown()
{
}
unittest(test_base)
{
AGS02MA AGS(26);
Wire.begin();
2021-09-24 06:31:48 -04:00
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", AGS02MA_LIB_VERSION);
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
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", AGS02MA_LIB_VERSION);
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()
// --------