forked from Mirrors/openclonk
Added more producer tests
parent
2ed69b96a5
commit
c6254c2512
|
@ -13,7 +13,7 @@
|
|||
@author Maikel (unit test logic), Marky (tests)
|
||||
*/
|
||||
|
||||
static const EXPECTED_TESTS = 15;
|
||||
static const EXPECTED_TESTS = 18;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
|
@ -833,8 +833,7 @@ global func Test15_OnStart(int plr)
|
|||
|
||||
global func Test15_Completed()
|
||||
{
|
||||
if (ObjectCount(Find_ID(Metal)) >= 5) return true;
|
||||
return false;
|
||||
return ObjectCount(Find_ID(Metal)) >= 5;
|
||||
}
|
||||
|
||||
global func Test15_OnFinished()
|
||||
|
@ -847,6 +846,113 @@ global func Test15_OnFinished()
|
|||
}
|
||||
|
||||
|
||||
// Producer with single substitute component
|
||||
global func Test16_OnStart(int plr)
|
||||
{
|
||||
// Producer: Foundry
|
||||
var producer = CreateObjectAbove(Foundry, 75, 160, plr);
|
||||
// The substitute component
|
||||
producer->CreateContents(Sand, 10);
|
||||
var barrel = CreateObject(Barrel);
|
||||
barrel->PutLiquid(Water, 300); // contains 300 water
|
||||
producer->AddToQueue(Loam, 5); // needs 300 water
|
||||
producer->Collect(barrel, true);
|
||||
|
||||
// Log what the test is about.
|
||||
Log("Objects with single substitute component (loam)");
|
||||
return true;
|
||||
}
|
||||
|
||||
global func Test16_Completed()
|
||||
{
|
||||
// The barrel must not be removed.
|
||||
return ObjectCount(Find_ID(Loam)) >= 5
|
||||
&& ObjectCount(Find_ID(Barrel)) >= 1;
|
||||
}
|
||||
|
||||
global func Test16_OnFinished()
|
||||
{
|
||||
// Remove wind generator, compensator and workshop.
|
||||
RemoveAll(Find_Or(Find_ID(Foundry), Find_ID(Loam), Find_ID(Barrel)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Producer with mixed single substitute component
|
||||
global func Test17_OnStart(int plr)
|
||||
{
|
||||
// Producer: Foundry
|
||||
var producer = CreateObjectAbove(Foundry, 75, 160, plr);
|
||||
// The substitute component, the last object should rely on 1 Earth and 1 Sand, which does not substitute here
|
||||
producer->CreateContents(Earth, 5);
|
||||
producer->CreateContents(Sand, 5);
|
||||
var barrel = CreateObject(Barrel);
|
||||
barrel->PutLiquid(Water, 300); // contains 300 water
|
||||
producer->AddToQueue(Loam, 5); // needs 300 water
|
||||
producer->Collect(barrel, true);
|
||||
|
||||
// Log what the test is about.
|
||||
Log("Objects with single substitute component (loam), mixing components is not possible");
|
||||
return true;
|
||||
}
|
||||
|
||||
global func Test17_Completed()
|
||||
{
|
||||
var producer = FindObject(Find_ID(Foundry));
|
||||
|
||||
if (!producer->IsProducing())
|
||||
{
|
||||
producer.test_production_stopped += 1;
|
||||
}
|
||||
|
||||
if (producer.test_production_stopped >= 35)
|
||||
{
|
||||
var passed = true;
|
||||
passed &= doTest("There is %d loam, should be %d", ObjectCount(Find_ID(Loam)), 4);
|
||||
passed &= doTest("There is %d barrel, should be %d", ObjectCount(Find_ID(Barrel)), 1);
|
||||
passed &= doTest("There is %d earth, should be %d", ObjectCount(Find_ID(Earth)), 1);
|
||||
passed &= doTest("There is %d sand, should be %d", ObjectCount(Find_ID(Sand)), 1);
|
||||
return passed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
global func Test17_OnFinished()
|
||||
{
|
||||
RemoveAll(Find_Or(Find_ID(Foundry), Find_ID(Loam), Find_ID(Barrel), Find_ID(Sand), Find_ID(Earth)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Producer with multiple substitute components
|
||||
global func Test18_OnStart(int plr)
|
||||
{
|
||||
// Producer: Foundry
|
||||
var producer = CreateObjectAbove(InventorsLab, 75, 160, plr);
|
||||
// The substitute component, the last object should rely on 1 Earth and 1 Sand, which does not substitute here
|
||||
producer->CreateContents(Metal, 6);
|
||||
producer->CreateContents(Diamond);
|
||||
producer->CreateContents(Ruby);
|
||||
producer->CreateContents(Amethyst);
|
||||
producer->AddToQueue(TeleGlove, 3);
|
||||
|
||||
// Log what the test is about.
|
||||
Log("Objects with multiple substitute components (TeleGlove)");
|
||||
return true;
|
||||
}
|
||||
|
||||
global func Test18_Completed()
|
||||
{
|
||||
return ObjectCount(Find_ID(TeleGlove)) >= 3;
|
||||
}
|
||||
|
||||
global func Test18_OnFinished()
|
||||
{
|
||||
RemoveAll(Find_Or(Find_ID(InventorsLab), Find_ID(TeleGlove)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Helper Functions --*/
|
||||
|
||||
global func doTest(description, returned, expected)
|
||||
|
|
Loading…
Reference in New Issue