// ArduinoJson - https://arduinojson.org // Copyright © 2014-2022, Benoit BLANCHON // MIT License #include #include #include using namespace ARDUINOJSON_NAMESPACE; TEST_CASE("canConvertNumber()") { SECTION("int8_t -> int8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(-128)) == true); } SECTION("int8_t -> int16_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(-128)) == true); } SECTION("int8_t -> uint8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(-128)) == false); } SECTION("int8_t -> uint16_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(-128)) == false); } SECTION("int16_t -> int8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(128)) == false); CHECK((canConvertNumber(-128)) == true); CHECK((canConvertNumber(-129)) == false); } SECTION("int16_t -> uint8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(255)) == true); CHECK((canConvertNumber(256)) == false); CHECK((canConvertNumber(-1)) == false); } SECTION("uint8_t -> int8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(128)) == false); CHECK((canConvertNumber(255)) == false); } SECTION("uint8_t -> int16_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(128)) == true); CHECK((canConvertNumber(255)) == true); } SECTION("uint8_t -> uint8_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(128)) == true); CHECK((canConvertNumber(255)) == true); } SECTION("uint8_t -> uint16_t") { CHECK((canConvertNumber(0)) == true); CHECK((canConvertNumber(127)) == true); CHECK((canConvertNumber(128)) == true); CHECK((canConvertNumber(255)) == true); } }