File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,13 @@ struct GasState {
117117 }
118118
119119 static void set_mix_rats (const GasState &self, const nlohmann::json &json) {
120+ if (json.size () == 0 )
121+ throw std::runtime_error (" Non-empty sequence of mixing ratios expected" );
122+
120123 GimmickGuard<InputGimmick> guard (json);
121- f_gas_state_from_json (self.ptr .f_arg (),
122- self.gas_data ->ptr .f_arg ());
124+ f_gas_state_from_json (
125+ self.ptr .f_arg (),
126+ self.gas_data ->ptr .f_arg ()
127+ );
123128 }
124129};
Original file line number Diff line number Diff line change @@ -130,3 +130,16 @@ def test_set_mix_rats_from_json():
130130 for i_spec in range (gas_data .n_spec ):
131131 if not i_spec in idx_set :
132132 assert sut [i_spec ] == 0
133+
134+ @staticmethod
135+ def test_set_mix_rats_empty ():
136+ # arrange
137+ gas_data = ppmc .GasData (("SO2" ,))
138+ sut = ppmc .GasState (gas_data )
139+
140+ # act
141+ with pytest .raises (RuntimeError ) as excinfo :
142+ sut .mix_rats = ()
143+
144+ # assert
145+ assert str (excinfo .value ) == "Non-empty sequence of mixing ratios expected"
You can’t perform that action at this time.
0 commit comments