From: <bur...@us...> - 2011-02-19 13:14:57
|
Revision: 8037 http://freecol.svn.sourceforge.net/freecol/?rev=8037&view=rev Author: burschik Date: 2011-02-19 13:14:51 +0000 (Sat, 19 Feb 2011) Log Message: ----------- Extend production tests. Modified Paths: -------------- freecol/trunk/src/net/sf/freecol/common/model/Building.java freecol/trunk/test/src/net/sf/freecol/common/model/ColonyProductionTest.java Modified: freecol/trunk/src/net/sf/freecol/common/model/Building.java =================================================================== --- freecol/trunk/src/net/sf/freecol/common/model/Building.java 2011-02-19 09:58:20 UTC (rev 8036) +++ freecol/trunk/src/net/sf/freecol/common/model/Building.java 2011-02-19 13:14:51 UTC (rev 8037) @@ -690,7 +690,8 @@ ? getAutoProduction(goods.getAmount()) : getProductionAdding(goods.getAmount()); result.addProduction(new AbstractGoods(getGoodsOutputType(), amount)); - result.addConsumption(new AbstractGoods(getGoodsInputType(), getGoodsInput())); + result.addConsumption(new AbstractGoods(getGoodsInputType(), + Math.min(getMaximumGoodsInput(), goods.getAmount()))); result.addMaximumProduction(new AbstractGoods(getGoodsOutputType(), getMaximumProduction())); break; } Modified: freecol/trunk/test/src/net/sf/freecol/common/model/ColonyProductionTest.java =================================================================== --- freecol/trunk/test/src/net/sf/freecol/common/model/ColonyProductionTest.java 2011-02-19 09:58:20 UTC (rev 8036) +++ freecol/trunk/test/src/net/sf/freecol/common/model/ColonyProductionTest.java 2011-02-19 13:14:51 UTC (rev 8037) @@ -393,8 +393,10 @@ GoodsType foodType = spec().getGoodsType("model.goods.food"); GoodsType grainType = spec().getGoodsType("model.goods.grain"); + GoodsType clothType = spec().getGoodsType("model.goods.cloth"); GoodsType bellsType = spec().getGoodsType("model.goods.bells"); GoodsType cottonType = spec().getGoodsType("model.goods.cotton"); + GoodsType horsesType = spec().getGoodsType("model.goods.horses"); GoodsType crossesType = spec().getGoodsType("model.goods.crosses"); assertEquals(0, colony.getGoodsCount(foodType)); @@ -443,6 +445,51 @@ assertEquals(7, grossProduction.getCount(foodType)); // this includes implicit type change and consumption assertEquals(14, netProduction.getCount(foodType)); + + colony.addGoods(horsesType, 50); + colony.getUnitList().get(0).setWorkType(cottonType); + Building weaverHouse = colony.getBuilding(spec().getBuildingType("model.building.weaverHouse")); + colony.getUnitList().get(1).setLocation(weaverHouse); + + info = colony.getProductionAndConsumption(); + grossProduction = new TypeCountMap<GoodsType>(); + netProduction = new TypeCountMap<GoodsType>(); + for (ProductionInfo productionInfo : info.values()) { + for (AbstractGoods goods : productionInfo.getProduction()) { + grossProduction.incrementCount(goods.getType(), goods.getAmount()); + netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount()); + } + for (AbstractGoods goods : productionInfo.getStorage()) { + grossProduction.incrementCount(goods.getType(), goods.getAmount()); + netProduction.incrementCount(goods.getType().getStoredAs(), goods.getAmount()); + } + for (AbstractGoods goods : productionInfo.getConsumption()) { + netProduction.incrementCount(goods.getType().getStoredAs(), -goods.getAmount()); + } + } + + assertEquals(4, grossProduction.getCount(cottonType)); + assertEquals(1, netProduction.getCount(cottonType)); + + assertEquals(3, grossProduction.getCount(clothType)); + assertEquals(3, netProduction.getCount(clothType)); + + assertEquals(10, grossProduction.getCount(grainType)); + assertEquals(0, netProduction.getCount(grainType)); + + assertEquals(2, grossProduction.getCount(horsesType)); + assertEquals(2, netProduction.getCount(horsesType)); + + assertEquals(1, grossProduction.getCount(bellsType)); + assertEquals(-2, netProduction.getCount(bellsType)); + + assertEquals(1, grossProduction.getCount(crossesType)); + assertEquals(1, netProduction.getCount(crossesType)); + + // this is storage only + assertEquals(2, grossProduction.getCount(foodType)); + // this includes implicit type change and consumption + assertEquals(2, netProduction.getCount(foodType)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |