GY-63_MS5611/libraries/Adler/test/unit_test_Adler16.cpp

97 lines
2.5 KiB
C++
Raw Normal View History

2022-06-16 03:46:28 -04:00
//
// FILE: unit_test_001.cpp
// AUTHOR: Rob Tillaart
// DATE: 2022-01-25
// PURPOSE: unit tests for the Adler library
// https://github.com/RobTillaart/Adler
// 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)
#include <ArduinoUnitTests.h>
#include "Arduino.h"
#include "Adler16.h"
char lorem[] = "Lorem ipsum dolor sit amet, \
consectetuer adipiscing elit. Aenean commodo ligula eget dolor. \
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient \
montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, \
pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. \
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. \
In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. \
Nullam dictum felis eu pede mollis pretium. Integer tincidunt. \
Cras dapibus. Vivamus elementum semper nisi. \
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, \
consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, \
viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus \
varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies \
nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.";
unittest_setup()
{
fprintf(stderr, "ADLER16_LIB_VERSION: %s\n", (char *) ADLER16_LIB_VERSION);
}
2023-01-16 10:33:37 -05:00
2022-06-16 03:46:28 -04:00
unittest_teardown()
{
}
unittest(test_constants)
{
assertEqual(ADLER16_MOD_PRIME, 251);
}
unittest(test_ADLER16_lorem)
{
Adler16 ad16;
ad16.begin();
2023-01-16 10:33:37 -05:00
2022-06-16 03:46:28 -04:00
fprintf(stderr, "strlen lorem\n");
assertEqual(868, strlen(lorem));
for (int i = 0; lorem[i] != 0; i++)
{
ad16.add(lorem[i]);
}
assertEqual(57303, ad16.getAdler());
2022-09-21 03:34:38 -04:00
assertEqual(868, ad16.count());
2022-06-16 03:46:28 -04:00
ad16.begin();
2022-09-21 03:34:38 -04:00
assertEqual(57303, ad16.add(lorem, strlen(lorem)));
2022-06-16 03:46:28 -04:00
assertEqual(57303, ad16.getAdler());
2022-09-21 03:34:38 -04:00
assertEqual(868, ad16.count());
2022-06-16 03:46:28 -04:00
ad16.begin();
2022-09-21 03:34:38 -04:00
assertEqual(57303, ad16.addFast(lorem, strlen(lorem)));
2022-06-16 03:46:28 -04:00
assertEqual(57303, ad16.getAdler());
2022-09-21 03:34:38 -04:00
assertEqual(868, ad16.count());
2022-06-16 03:46:28 -04:00
}
unittest_main()
2023-01-16 10:33:37 -05:00
// -- END OF FILE --