From 74fc6d3995fdaff4de645f0540a36109674366fa Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Fri, 28 Oct 2022 11:39:46 +0200 Subject: [PATCH] add automated test for pascal string literals --- AutomatedTests/CMakeLists.txt | 2 ++ AutomatedTests/PascalString.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 AutomatedTests/PascalString.c diff --git a/AutomatedTests/CMakeLists.txt b/AutomatedTests/CMakeLists.txt index 3e670a38a0..e07c21bf98 100644 --- a/AutomatedTests/CMakeLists.txt +++ b/AutomatedTests/CMakeLists.txt @@ -86,3 +86,5 @@ test(Exceptions.cc PROPERTIES PASS_REGULAR_EXPRESSION "OK") configure_file(PascalTrap.c PascalTrapCPP.cc) test(PascalTrap.c PROPERTIES PASS_REGULAR_EXPRESSION "OK") test(${CMAKE_CURRENT_BINARY_DIR}/PascalTrapCPP.cc PROPERTIES PASS_REGULAR_EXPRESSION "OK") + +test(PascalString.c PROPERTIES PASS_REGULAR_EXPRESSION "OK") diff --git a/AutomatedTests/PascalString.c b/AutomatedTests/PascalString.c new file mode 100644 index 0000000000..15c825e063 --- /dev/null +++ b/AutomatedTests/PascalString.c @@ -0,0 +1,25 @@ +#include "Test.h" + +int main() +{ + const unsigned char *pstr = "\pHello, world."; + const char *cstr = "Hello, world."; + + if (pstr[0] != 13) + { + TEST_LOG_NO(); + return 1; + } + + for (int i = 0; cstr[i]; ++i) + { + if (cstr[i] != (char) pstr[i+1]) + { + TEST_LOG_NO(); + return 1; + } + } + + TEST_LOG_OK(); + return 0; +}