-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from open-atmos/parse_wet_deposition
Parse wet deposition
- Loading branch information
Showing
11 changed files
with
191 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <open_atmos/mechanism_configuration/parser.hpp> | ||
|
||
using namespace open_atmos::mechanism_configuration; | ||
|
||
TEST(JsonParser, CanParseValidWetDepositionReaction) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/wet_deposition/valid.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::Success); | ||
|
||
EXPECT_EQ(mechanism.reactions.wet_deposition.size(), 2); | ||
|
||
EXPECT_EQ(mechanism.reactions.wet_deposition[0].name, "rxn cloud"); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[0].aerosol_phase, "cloud"); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[0].scaling_factor, 12.3); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[0].unknown_properties.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[0].unknown_properties["__comment"], "\"Tuxedo cats are the best\""); | ||
|
||
EXPECT_EQ(mechanism.reactions.wet_deposition[1].name, "rxn cloud2"); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[1].aerosol_phase, "cloud"); | ||
EXPECT_EQ(mechanism.reactions.wet_deposition[1].scaling_factor, 1); | ||
} | ||
|
||
TEST(JsonParser, WetDepositionDetectsUnknownPhase) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/wet_deposition/missing_phase.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::UnknownPhase); | ||
} |
24 changes: 24 additions & 0 deletions
24
test/unit/unit_configs/reactions/wet_deposition/missing_phase.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Missing phase", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
} | ||
], | ||
"phases": [ | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "WET_DEPOSITION", | ||
"aerosol phase": "cloud", | ||
"name": "rxn cloud" | ||
} | ||
] | ||
} |
39 changes: 39 additions & 0 deletions
39
test/unit/unit_configs/reactions/wet_deposition/valid.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Valid wet deposition", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "cloud", | ||
"species": [ | ||
"A", | ||
"B", | ||
"C" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "WET_DEPOSITION", | ||
"aerosol phase": "cloud", | ||
"name": "rxn cloud", | ||
"scaling factor": 12.3, | ||
"__comment": "Tuxedo cats are the best" | ||
}, | ||
{ | ||
"type": "WET_DEPOSITION", | ||
"aerosol phase": "cloud", | ||
"name": "rxn cloud2" | ||
} | ||
] | ||
} |