@@ -161,6 +161,57 @@ TEST_CASE( "proc_food_remaining_size_tracks_servings", "[proc][make][food]" )
161161 CHECK ( proc::blob_kcal ( *made ) == starting_kcal );
162162}
163163
164+ TEST_CASE ( " proc_make_item_scales_stew_servings_with_total_size" , " [proc][make][food]" )
165+ {
166+ auto sch = proc::schema{};
167+ sch.id = proc::schema_id ( " stew" );
168+ sch.cat = " food" ;
169+ sch.res = itype_id ( " stew_generic" );
170+ sch.slots = {
171+ proc::slot_data{ .id = proc::slot_id ( " base" ), .role = " base" , .min = 1 , .max = 1 , .ok = {}, .no = {} },
172+ proc::slot_data{ .id = proc::slot_id ( " veg" ), .role = " veg" , .min = 1 , .max = 4 , .rep = true , .ok = {}, .no = {} }
173+ };
174+
175+ auto broth = proc::part_fact{};
176+ broth.ix = 1 ;
177+ broth.id = itype_id ( " broth" );
178+ broth.kcal = 600 ;
179+ broth.mass_g = 2200 ;
180+ broth.volume_ml = 2200 ;
181+
182+ auto carrot = proc::part_fact{};
183+ carrot.ix = 2 ;
184+ carrot.id = itype_id ( " carrot" );
185+ carrot.kcal = 300 ;
186+ carrot.mass_g = 1800 ;
187+ carrot.volume_ml = 1800 ;
188+
189+ auto opts = proc::make_opts{};
190+ opts.mode = proc::hist::none;
191+ opts.slots = { proc::slot_id ( " base" ), proc::slot_id ( " veg" ) };
192+ const auto made = proc::make_item ( sch, { broth, carrot }, opts );
193+
194+ const auto base = item ( " stew_generic" , calendar::turn );
195+ const auto ceil_div = []( const int value, const int divisor ) {
196+ return value <= 0 ? 0 : ( value + divisor - 1 ) / divisor;
197+ };
198+ const auto base_servings = std::max ( base.charges , 1 );
199+ const auto expected_servings = std::max ( {
200+ base_servings,
201+ ceil_div ( ( broth.mass_g + carrot.mass_g ) * base_servings,
202+ std::max ( units::to_gram ( base.weight () ), 1L ) ),
203+ ceil_div ( ( broth.volume_ml + carrot.volume_ml ) * base_servings,
204+ std::max ( units::to_milliliter ( base.volume () ), 1 ) )
205+ } );
206+
207+ REQUIRE ( proc::read_payload ( *made ) );
208+ CHECK ( made->charges == expected_servings );
209+ CHECK ( proc::read_payload ( *made )->servings == expected_servings );
210+ CHECK ( made->charges > base_servings );
211+ CHECK ( made->weight () == units::from_gram ( 4000 ) );
212+ CHECK ( made->volume () == units::from_milliliter ( 4000 ) );
213+ }
214+
164215TEST_CASE ( " proc_food_uses_blob_nutrition_and_component_hash" , " [proc][make][food]" )
165216{
166217 auto sch = proc::schema{};
0 commit comments