mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-19 18:11:39 -05:00
Add a test to ensure support for trailing commas in settings.json (#6312)
## Summary of the Pull Request Adds support for trailing commas in our json files. ## References * Enabled due to the excellent work over in https://github.com/open-source-parsers/jsoncpp/pull/1098 ## PR Checklist * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated
This commit is contained in:
@@ -78,6 +78,8 @@ namespace TerminalAppLocalTests
|
|||||||
|
|
||||||
TEST_METHOD(ValidateLegacyGlobalsWarning);
|
TEST_METHOD(ValidateLegacyGlobalsWarning);
|
||||||
|
|
||||||
|
TEST_METHOD(TestTrailingCommas);
|
||||||
|
|
||||||
TEST_CLASS_SETUP(ClassSetup)
|
TEST_CLASS_SETUP(ClassSetup)
|
||||||
{
|
{
|
||||||
InitializeJsonReader();
|
InitializeJsonReader();
|
||||||
@@ -2294,4 +2296,39 @@ namespace TerminalAppLocalTests
|
|||||||
VERIFY_ARE_EQUAL(1u, settings._warnings.size());
|
VERIFY_ARE_EQUAL(1u, settings._warnings.size());
|
||||||
VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::LegacyGlobalsProperty, settings._warnings.at(0));
|
VERIFY_ARE_EQUAL(::TerminalApp::SettingsLoadWarnings::LegacyGlobalsProperty, settings._warnings.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsTests::TestTrailingCommas()
|
||||||
|
{
|
||||||
|
const std::string badSettings{ R"(
|
||||||
|
{
|
||||||
|
"defaultProfile": "{6239a42c-2222-49a3-80bd-e8fdd045185c}",
|
||||||
|
"profiles": [
|
||||||
|
{
|
||||||
|
"name" : "profile0",
|
||||||
|
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "profile1",
|
||||||
|
"guid": "{6239a42c-3333-49a3-80bd-e8fdd045185c}"
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"keybindings": [],
|
||||||
|
})" };
|
||||||
|
|
||||||
|
// Create the default settings
|
||||||
|
CascadiaSettings settings;
|
||||||
|
settings._ParseJsonString(DefaultJson, true);
|
||||||
|
settings.LayerJson(settings._defaultSettings);
|
||||||
|
|
||||||
|
// Now layer on the user's settings
|
||||||
|
try
|
||||||
|
{
|
||||||
|
settings._ParseJsonString(badSettings, false);
|
||||||
|
settings.LayerJson(settings._userSettings);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
VERIFY_IS_TRUE(false, L"This call to LayerJson should succeed, even with the trailing comma");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user