Liskov principle and unittest
mta`chrono
chrono at mta-international.net
Fri Sep 23 03:59:09 PDT 2011
class Superclass
{
abstract int do_some_stuff();
abstract int do_some_other_stuff();
}
class Foo1 : Superclass....
class Foo2 : Superclass....
class Foo3 : Superclass....
unittest
{
// get an instance of all classes
Superclass[] instances = [new Foo1(), new Foo2(), new Foo3()];
// test their behavoir
foreach(instance; instances)
{
assert(instance.do_some_stuff() > 0, "whoops!");
assert(instance.do_some_other_stuff() < 100, "whoops!");
}
}
More information about the Digitalmars-d
mailing list