From a6cbdc2f13da9d22557197a7532ca676e5a8c987 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 11 Jul 2015 21:34:01 -0700 Subject: [PATCH] Add test for recently discovered bug in stack-buffer-constructed plStrings --- Sources/Tests/CoreTests/test_plString.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/Tests/CoreTests/test_plString.cpp b/Sources/Tests/CoreTests/test_plString.cpp index 3d2768a1..970e2522 100644 --- a/Sources/Tests/CoreTests/test_plString.cpp +++ b/Sources/Tests/CoreTests/test_plString.cpp @@ -85,6 +85,22 @@ TEST(plString, Utility) EXPECT_EQ(utf8_test_data_length, plString(utf8_test_data).GetSize()); } +TEST(plString, StackStrings) +{ + char stack_buf[256]; + strcpy(stack_buf, "Test"); + plString test(stack_buf); + + EXPECT_EQ(plString("Test"), test); + EXPECT_EQ(strlen("Test"), test.GetSize()); + + strcpy(stack_buf, "operator="); + test = stack_buf; + + EXPECT_EQ(plString("operator="), test); + EXPECT_EQ(strlen("operator="), test.GetSize()); +} + TEST(plString, ConvertUtf8) { // From UTF-8 to plString