add automated test for pascal string literals

This commit is contained in:
Wolfgang Thaller 2022-10-28 11:39:46 +02:00
parent ca8e6715cb
commit 74fc6d3995
2 changed files with 27 additions and 0 deletions

View File

@ -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")

View File

@ -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;
}