From 24d173c3b97b61e05b825a88fd018f753a99d457 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Thu, 4 Sep 2014 21:30:50 +0200 Subject: [PATCH] Added tests of escaped chars --- JsonParserTests/JsonStringTests.cpp | 52 +++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/JsonParserTests/JsonStringTests.cpp b/JsonParserTests/JsonStringTests.cpp index 7c22b5bc..d19126ef 100644 --- a/JsonParserTests/JsonStringTests.cpp +++ b/JsonParserTests/JsonStringTests.cpp @@ -33,8 +33,56 @@ namespace ArduinoJsonParserTests TEST_METHOD(EscapedQuote) { - whenInputIs("\\\""); - outputMustBe("\""); + whenInputIs("\"12\\\"34\""); // ie 12\"34 + outputMustBe("12\"34"); + } + + TEST_METHOD(EscapedReverseSolidus) + { + whenInputIs("\"12\\\\34\""); // ie 12\\34 + outputMustBe("12\\34"); + } + + TEST_METHOD(EscapedSolidus) + { + whenInputIs("\"12\\/34\""); + outputMustBe("12/34"); + } + + TEST_METHOD(EscapedBackspace) + { + whenInputIs("\"12\\b34\""); + outputMustBe("12\b34"); + } + + TEST_METHOD(EscapedFormfeed) + { + whenInputIs("\"12\\f34\""); + outputMustBe("12\f34"); + } + + TEST_METHOD(EscapedNewline) + { + whenInputIs("\"12\\n34\""); + outputMustBe("12\n34"); + } + + TEST_METHOD(EscapedCarriageReturn) + { + whenInputIs("\"12\\r34\""); + outputMustBe("12\r34"); + } + + TEST_METHOD(EscapedTab) + { + whenInputIs("\"12\\t34\""); + outputMustBe("12\t34"); + } + + TEST_METHOD(AllEscapedCharsTogether) + { + whenInputIs("1\\\"2\\\\3\\/4\\b5\\f6\\n7\\r8\\t9\""); + outputMustBe("1\"2\\3/4\b5\f6\n7\r8\t9"); } private: