Closed I-Campbell closed 4 years ago
AssertEquals(Any) doesn't support the BIT-type (yet, I guess it would make sense to add). A Bit takes up a full byte in TwinCAT. BIT can only be used in structures and function blocks, and not as inputs (that's why there is not AssertEquals_BIT). Documentation should be updated for the AssertEquals(Any) to highlight which types are supported.
I tried to implement support for BIT but was just reminded that it's actually not possible. There is no way to have var_inputs to bits and thus with the current design of TcUnit it's not possible to add it. One possibility is to simply use the BOOL-variant and do a TO_BOOL (or BIT_TO_BOOL) conversion prior to asserting.
I can indeed confirm that a BIT_TO_BOOL-conversion works just fine. I have added an example to the F.A.Q. of TcUnit: https://tcunit.org/frequently-asked-questions/?Display_FAQ=871
If the BITS are in the same BYTE it will fail to detect an Assert Failure. (Ie. always asserts pass) If the BITS are in different BYTES it will give an Assert Failure all the time, unless the other bits are identical. Two incorrect asserts shown below (first one Fails, when it should succeed. Second Succeeds when it should fail)