Skip to content

Commit

Permalink
Add a test to ensure support for trailing commas in settings.json (…
Browse files Browse the repository at this point in the history
…#6312)

## Summary of the Pull Request

Adds support for trailing commas in our json files. 

## References

* Enabled due to the excellent work over in open-source-parsers/jsoncpp#1098

## PR Checklist
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
  • Loading branch information
donno2048 committed Jun 4, 2020
1 parent 2e8aed3 commit 494e45f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ namespace TerminalAppLocalTests

TEST_METHOD(ValidateLegacyGlobalsWarning);

TEST_METHOD(TestTrailingCommas);

TEST_CLASS_SETUP(ClassSetup)
{
InitializeJsonReader();
Expand Down Expand Up @@ -2294,4 +2296,39 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(1u, settings._warnings.size());
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");
}
}
}

0 comments on commit 494e45f

Please sign in to comment.