/
SoRusV
/
AquaController2
Обзор
Документация
Войти
/
SoRusV
/
AquaController2
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
libraries/ArduinoJson/test/JsonWriter/writeString.cpp
61 строка
1 KB
Vteselkin
-add support libraries
29 окт 2020, 22:01
29 окт 2020, 22:01
b1654a8
Код
Авторство
О чём код?
// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #include <catch.hpp> #include <ArduinoJson/Serialization/JsonWriter.hpp> #include <ArduinoJson/Serialization/StaticStringBuilder.hpp> using namespace ArduinoJson::Internals; void check(const char* input, std::string expected) { char output[1024]; StaticStringBuilder sb(output, sizeof(output)); JsonWriter<StaticStringBuilder> writer(sb); writer.writeString(input); REQUIRE(expected == output); REQUIRE(writer.bytesWritten() == expected.size()); } TEST_CASE("JsonWriter::writeString()") { SECTION("Null") { check(0, "null"); } SECTION("EmptyString") { check("", "\"\""); } SECTION("QuotationMark") { check("\"", "\"\\\"\""); } SECTION("ReverseSolidus") { check("\\", "\"\\\\\""); } SECTION("Solidus") { check("/", "\"/\""); // but the JSON format allows \/ } SECTION("Backspace") { check("\b", "\"\\b\""); } SECTION("Formfeed") { check("\f", "\"\\f\""); } SECTION("Newline") { check("\n", "\"\\n\""); } SECTION("CarriageReturn") { check("\r", "\"\\r\""); } SECTION("HorizontalTab") { check("\t", "\"\\t\""); } }