@@ -113,18 +113,30 @@ TEST(FormatsYamlDuplicateKeys, VariousScalarsInMapKeys) {
113113}
114114
115115TEST (FormatsYamlDuplicateKeys, NonScalarsInMapKeys) {
116- {
117- const std::string yaml_string = R"(
118- [1, 2, 3]: foo
119- [1, 2, 3]: bar
120- )" ;
121- formats::yaml::Value value;
122- // This check relies on implementation of FromString. Currently, we do not throw an exception in this case,
123- // but we could do so in the future. In that case the test should be changed.
124- // Anyway, we should not hang or crash here.
125- UEXPECT_NO_THROW (value = formats::yaml::FromString (yaml_string));
126- EXPECT_EQ (value.GetSize (), 2 );
127- }
116+ const std::string yaml_string = R"(
117+ [1, 2, 3]: foo
118+ [1, 2, 3]: bar
119+ )" ;
120+ formats::yaml::Value value;
121+ // This check relies on implementation of FromString. Currently, we do not throw an exception in this case,
122+ // but we could do so in the future. In that case the test should be changed.
123+ // Anyway, we should not hang or crash here.
124+ UEXPECT_NO_THROW (value = formats::yaml::FromString (yaml_string));
125+ EXPECT_EQ (value.GetSize (), 2 );
126+ }
127+
128+ TEST (FormatsYamlDuplicateKeys, SameKeysInDifferentNestingLevels) {
129+ const std::string yaml_string = R"(
130+ Key1: &values
131+ Key1: &keys
132+ Key1: 1
133+ Key2: 2
134+ Key3: 3
135+ Key2: *keys
136+ Key3: *keys
137+ Key2: *values
138+ )" ;
139+ UEXPECT_NO_THROW (formats::yaml::FromString (yaml_string));
128140}
129141
130142USERVER_NAMESPACE_END
0 commit comments