Added some rudimentary unittests that should have their order enforced

else stuff can go really wrong, these things run as part of a single process,
no restarts etc. Hence state is persisted across unittests
This commit is contained in:
Tristan B. Velloza Kildaire 2022-05-24 19:53:26 +02:00
parent 0d850d0508
commit 246adcc1f9
1 changed files with 94 additions and 0 deletions

View File

@ -319,6 +319,100 @@ public abstract class Descriptor : Signal
}
/**
* Tests custom descriptor IDs
*
* FIXME: The unittest ordering to be kinda important
*/
unittest
{
/**
* Add a descriptor with ID 1, this should pass
*/
try
{
class DescTest : Descriptor
{
this()
{
super(1);
}
public override void handler(Event e)
{
writeln("Event id ", e.id);
}
}
Descriptor newDesc = new DescTest();
assert(newDesc.getDescriptorClass() == 1);
}
catch(DescriptorException e)
{
assert(false);
}
}
unittest
{
/**
* Add a descriptor with ID 2, this should pass
*/
try
{
class DescTest : Descriptor
{
this()
{
super(2);
}
public override void handler(Event e)
{
writeln("Event id ", e.id);
}
}
Descriptor newDesc = new DescTest();
assert(newDesc.getDescriptorClass() == 2);
}
catch(DescriptorException e)
{
assert(false);
}
}
unittest
{
/**
* Add a descriptor with ID 2, this should pass
*/
try
{
class DescTest : Descriptor
{
this()
{
super(2);
}
public override void handler(Event e)
{
writeln("Event id ", e.id);
}
}
Descriptor newDesc = new DescTest();
assert(false);
}
catch(DescriptorException e)
{
assert(true);
}
}
unittest
{