equals.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #include <ArduinoJson.h>
  5. #include <catch.hpp>
  6. TEST_CASE("JsonArray::operator==()") {
  7. DynamicJsonDocument doc1(4096);
  8. JsonArray array1 = doc1.to<JsonArray>();
  9. JsonArrayConst array1c = array1;
  10. DynamicJsonDocument doc2(4096);
  11. JsonArray array2 = doc2.to<JsonArray>();
  12. JsonArrayConst array2c = array2;
  13. SECTION("should return false when arrays differ") {
  14. array1.add("coucou");
  15. array2.add(1);
  16. REQUIRE_FALSE(array1 == array2);
  17. REQUIRE_FALSE(array1c == array2c);
  18. }
  19. SECTION("should return false when LHS has more elements") {
  20. array1.add(1);
  21. array1.add(2);
  22. array2.add(1);
  23. REQUIRE_FALSE(array1 == array2);
  24. REQUIRE_FALSE(array1c == array2c);
  25. }
  26. SECTION("should return false when RKS has more elements") {
  27. array1.add(1);
  28. array2.add(1);
  29. array2.add(2);
  30. REQUIRE_FALSE(array1 == array2);
  31. REQUIRE_FALSE(array1c == array2c);
  32. }
  33. SECTION("should return true when arrays equal") {
  34. array1.add("coucou");
  35. array2.add("coucou");
  36. REQUIRE(array1 == array2);
  37. REQUIRE(array1c == array2c);
  38. }
  39. }