// ArduinoJson - https://arduinojson.org // Copyright © 2014-2023, Benoit BLANCHON // MIT License #include #include #include #include #include using namespace ArduinoJson::detail; template void checkWriteInteger(T value, std::string expected) { char output[64] = {0}; StaticStringWriter sb(output, sizeof(output)); TextFormatter writer(sb); writer.writeInteger(value); REQUIRE(expected == output); REQUIRE(writer.bytesWritten() == expected.size()); } TEST_CASE("int8_t") { checkWriteInteger(0, "0"); checkWriteInteger(-128, "-128"); checkWriteInteger(127, "127"); } TEST_CASE("uint8_t") { checkWriteInteger(0, "0"); checkWriteInteger(255, "255"); } TEST_CASE("int16_t") { checkWriteInteger(0, "0"); checkWriteInteger(-32768, "-32768"); checkWriteInteger(32767, "32767"); } TEST_CASE("uint16_t") { checkWriteInteger(0, "0"); checkWriteInteger(65535, "65535"); } TEST_CASE("int32_t") { checkWriteInteger(0, "0"); checkWriteInteger(-2147483647 - 1, "-2147483648"); checkWriteInteger(2147483647, "2147483647"); } TEST_CASE("uint32_t") { checkWriteInteger(0, "0"); checkWriteInteger(4294967295U, "4294967295"); }