I am trying to check if a bit is set, or not set, in a 32-bit word.  I
made an enumeration to name the bits, Bits.Bit1, Bits.Bit2 etc.  Since
I have to test for a lot of these I would like it to be as straight
forward and simple an assertion as possible without requiring all this
typecasting.

Right now I have been doing the following which I consider to be
rather blunt.

Assert.AreEqual(0, data & (int)Bits.BIT11, "Bit 11 is set");
and the reverse
Assert.AreEqual((int) Bits.BIT11, data & (int)Bits.BIT11, "Bit 11 is
not set");

One problem with this is that when it fails I get the integer value of
the expected value and the result of the bitwise & on the data when I
would prefer to get expected 0, was 1, expected 1 was 0.  I know I
could shift the bits but that complicates the assert when I want to
change the bit I am testing.

Is this something where I should write my own assertion or is there a
neat trick anyone knows of that would help?

Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to