-
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.
- Loading branch information
Showing
9 changed files
with
301 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <open_atmos/mechanism_configuration/parser.hpp> | ||
|
||
using namespace open_atmos::mechanism_configuration; | ||
|
||
TEST(JsonParser, CanParseValidFirstOrderLossReaction) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/first_order_loss/valid.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::Success); | ||
|
||
EXPECT_EQ(mechanism.reactions.first_order_loss.size(), 2); | ||
|
||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].name, "my first order loss"); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].scaling_factor_, 12.3); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].products.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].products[0].species_name, "C"); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].products[0].coefficient, 1); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].unknown_properties.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[0].unknown_properties["__comment"], "\"Strawberries are the superior fruit\""); | ||
|
||
EXPECT_EQ(mechanism.reactions.first_order_loss[1].gas_phase, "gas"); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[1].scaling_factor_, 1); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[1].products.size(), 1); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[1].products[0].species_name, "C"); | ||
EXPECT_EQ(mechanism.reactions.first_order_loss[1].products[0].coefficient, 1); | ||
} | ||
|
||
TEST(JsonParser, FirstOrderLossDetectsUnknownSpecies) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/first_order_loss/unknown_species.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::ReactionRequiresUnknownSpecies); | ||
} | ||
|
||
TEST(JsonParser, FirstOrderLossDetectsBadReactionComponent) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/first_order_loss/bad_reaction_component.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::RequiredKeyNotFound); | ||
} | ||
|
||
TEST(JsonParser, FirstOrderLossDetectsUnknownPhase) | ||
{ | ||
JsonParser parser; | ||
auto [status, mechanism] = parser.Parse(std::string("unit_configs/reactions/first_order_loss/missing_phase.json")); | ||
EXPECT_EQ(status, ConfigParseStatus::UnknownPhase); | ||
} |
32 changes: 32 additions & 0 deletions
32
test/unit/unit_configs/reactions/first_order_loss/bad_reaction_component.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,32 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Bad reaction component", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "gas", | ||
"species": [ | ||
"A", | ||
"B" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "FIRST_ORDER_LOSS", | ||
"gas phase": "gas", | ||
"products": [ | ||
{ | ||
"Species name": "C" | ||
} | ||
] | ||
} | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
test/unit/unit_configs/reactions/first_order_loss/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,27 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Missing phase", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
} | ||
], | ||
"phases": [ ], | ||
"reactions": [ | ||
{ | ||
"type": "FIRST_ORDER_LOSS", | ||
"gas phase": "gas", | ||
"products": [ | ||
{ | ||
"species name": "C" | ||
} | ||
] | ||
} | ||
] | ||
} |
32 changes: 32 additions & 0 deletions
32
test/unit/unit_configs/reactions/first_order_loss/unknown_species.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,32 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Unknown species", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "gas", | ||
"species": [ | ||
"A", | ||
"B" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "FIRST_ORDER_LOSS", | ||
"gas phase": "gas", | ||
"products": [ | ||
{ | ||
"species name": "C" | ||
} | ||
] | ||
} | ||
] | ||
} |
58 changes: 58 additions & 0 deletions
58
test/unit/unit_configs/reactions/first_order_loss/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,58 @@ | ||
{ | ||
"version": "1.0.0", | ||
"name": "Valid surface", | ||
"species": [ | ||
{ | ||
"name": "A" | ||
}, | ||
{ | ||
"name": "B" | ||
}, | ||
{ | ||
"name": "C" | ||
} | ||
], | ||
"phases": [ | ||
{ | ||
"name": "gas", | ||
"species": [ | ||
"A", | ||
"B", | ||
"C" | ||
] | ||
}, | ||
{ | ||
"name": "surface reacting phase", | ||
"species": [ | ||
"A", | ||
"B", | ||
"C" | ||
] | ||
} | ||
], | ||
"reactions": [ | ||
{ | ||
"type": "FIRST_ORDER_LOSS", | ||
"gas phase": "gas", | ||
"products": [ | ||
{ | ||
"species name": "C", | ||
"coefficient": 1 | ||
} | ||
], | ||
"name": "my first order loss", | ||
"scaling factor": 12.3, | ||
"__comment": "Strawberries are the superior fruit" | ||
}, | ||
{ | ||
"type": "FIRST_ORDER_LOSS", | ||
"gas phase": "gas", | ||
"products": [ | ||
{ | ||
"species name": "C", | ||
"coefficient": 1 | ||
} | ||
] | ||
} | ||
] | ||
} |