MCPcopy Create free account
hub / github.com/cpputest/cpputest / StringFromMaskedBits

Function StringFromMaskedBits

src/CppUTest/SimpleString.cpp:920–943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_t byteCount)
921{
922 SimpleString result;
923 size_t bitCount = (byteCount > sizeof(unsigned long)) ? (sizeof(unsigned long) * CPPUTEST_CHAR_BIT) : (byteCount * CPPUTEST_CHAR_BIT);
924 const unsigned long msbMask = (((unsigned long) 1) << (bitCount - 1));
925
926 for (size_t i = 0; i < bitCount; i++) {
927 if (mask & msbMask) {
928 result += (value & msbMask) ? "1" : "0";
929 }
930 else {
931 result += "x";
932 }
933
934 if (((i % 8) == 7) && (i != (bitCount - 1))) {
935 result += " ";
936 }
937
938 value <<= 1;
939 mask <<= 1;
940 }
941
942 return result;
943}
944
945SimpleString StringFromOrdinalNumber(unsigned int number)
946{

Callers 2

BitsEqualFailureMethod · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 2

BitsEqualFailureMethod · 0.68
TESTFunction · 0.68