@@ -1516,6 +1516,29 @@ JSONTEST_FIXTURE(ValueTest, offsetAccessors) {
15161516 JSONTEST_ASSERT (y.getOffsetLimit () == 0 );
15171517}
15181518
1519+ JSONTEST_FIXTURE (ValueTest, StaticString) {
1520+ char mutant[] = " hello" ;
1521+ Json::StaticString ss (mutant);
1522+ std::string regular (mutant);
1523+ mutant[1 ] = ' a' ;
1524+ JSONTEST_ASSERT_STRING_EQUAL (" hallo" , ss.c_str ());
1525+ JSONTEST_ASSERT_STRING_EQUAL (" hello" , regular.c_str ());
1526+ {
1527+ Json::Value root;
1528+ root[" top" ] = ss;
1529+ JSONTEST_ASSERT_STRING_EQUAL (" hallo" , root[" top" ].asString ());
1530+ mutant[1 ] = ' u' ;
1531+ JSONTEST_ASSERT_STRING_EQUAL (" hullo" , root[" top" ].asString ());
1532+ }
1533+ {
1534+ Json::Value root;
1535+ root[" top" ] = regular;
1536+ JSONTEST_ASSERT_STRING_EQUAL (" hello" , root[" top" ].asString ());
1537+ mutant[1 ] = ' u' ;
1538+ JSONTEST_ASSERT_STRING_EQUAL (" hello" , root[" top" ].asString ());
1539+ }
1540+ }
1541+
15191542struct WriterTest : JsonTest::TestCase {};
15201543
15211544JSONTEST_FIXTURE (WriterTest, dropNullPlaceholders) {
@@ -2083,6 +2106,7 @@ int main(int argc, const char* argv[]) {
20832106 JSONTEST_REGISTER_FIXTURE (runner, ValueTest, compareType);
20842107 JSONTEST_REGISTER_FIXTURE (runner, ValueTest, offsetAccessors);
20852108 JSONTEST_REGISTER_FIXTURE (runner, ValueTest, typeChecksThrowExceptions);
2109+ JSONTEST_REGISTER_FIXTURE (runner, ValueTest, StaticString);
20862110
20872111 JSONTEST_REGISTER_FIXTURE (runner, WriterTest, dropNullPlaceholders);
20882112 JSONTEST_REGISTER_FIXTURE (runner, StreamWriterTest, dropNullPlaceholders);
0 commit comments