Unittest Absurdity

Ruby The Roobster rubytheroobster at yandex.com
Fri Aug 5 01:23:40 UTC 2022


How do I get unittests to actually execute operator overloads?

E.g.:

```d
struct Struct
{
     void opOpAssign(string op)(Struct rhs) //Assume that the 
operator `/=` is implemented here
     {
         //...
     }
}

unittest
{
    Struct a = Struct(1);

    Struct b = Struct(2);

    a /= b;

    assert(a == Struct(5, 0, -1));
}
```

The unittest completely ignores the `a /= b`.

Unittests also ignore swapping `a` for `a/b` in the `assert` 
statement, and even if I force the operator overloads to give me 
the correct answers, the `assert` still fails.

Any function other than an operator overload seems to work fine.


More information about the Digitalmars-d-learn mailing list