enable_alignment_0.cpp 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #define ARDUINOJSON_NAMESPACE ArduinoJson_NoAlignment
  2. #define ARDUINOJSON_ENABLE_ALIGNMENT 0
  3. #include <ArduinoJson.h>
  4. #include <catch.hpp>
  5. TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 0") {
  6. using namespace ARDUINOJSON_NAMESPACE;
  7. const size_t N = sizeof(void*);
  8. SECTION("isAligned()") {
  9. CHECK(isAligned(0) == true);
  10. CHECK(isAligned(1) == true);
  11. CHECK(isAligned(N) == true);
  12. CHECK(isAligned(N + 1) == true);
  13. CHECK(isAligned(2 * N) == true);
  14. CHECK(isAligned(2 * N + 1) == true);
  15. }
  16. SECTION("addPadding()") {
  17. CHECK(addPadding(0) == 0);
  18. CHECK(addPadding(1) == 1);
  19. CHECK(addPadding(N) == N);
  20. CHECK(addPadding(N + 1) == N + 1);
  21. }
  22. SECTION("AddPadding<>") {
  23. const size_t a = AddPadding<0>::value;
  24. CHECK(a == 0);
  25. const size_t b = AddPadding<1>::value;
  26. CHECK(b == 1);
  27. const size_t c = AddPadding<N>::value;
  28. CHECK(c == N);
  29. const size_t d = AddPadding<N + 1>::value;
  30. CHECK(d == N + 1);
  31. }
  32. }