summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-02-24 16:05:48 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-02-25 22:35:44 +0100
commit6a5ef46dd018c8e66e341a531403e40de24893f2 (patch)
tree58b1fd6b36b0939028c7395d5c943d517d901787 /tests
parentf81eb328b61f65a09b7233aaa70b2f655c0300bc (diff)
Add byte printing macros
It's sometimes handy for debugging to be able to immediately see which bits are set in a given byte. Generalize macro used for that in bitvec tests and make it available for the rest of the library.
Diffstat (limited to 'tests')
-rw-r--r--tests/bitvec/bitvec_test.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/tests/bitvec/bitvec_test.c b/tests/bitvec/bitvec_test.c
index 800a0406..76d6773e 100644
--- a/tests/bitvec/bitvec_test.c
+++ b/tests/bitvec/bitvec_test.c
@@ -11,17 +11,6 @@
#include <osmocom/core/bitvec.h>
#include <osmocom/core/bits.h>
-#define BIN_PATTERN "%d%d%d%d%d%d%d%d"
-#define BIN(byte) \
- (byte & 0x80 ? 1 : 0), \
- (byte & 0x40 ? 1 : 0), \
- (byte & 0x20 ? 1 : 0), \
- (byte & 0x10 ? 1 : 0), \
- (byte & 0x08 ? 1 : 0), \
- (byte & 0x04 ? 1 : 0), \
- (byte & 0x02 ? 1 : 0), \
- (byte & 0x01 ? 1 : 0)
-
static char lol[1024]; // we pollute this with printed vectors
static inline void test_rl(const struct bitvec *bv)
{
@@ -45,7 +34,7 @@ static inline void test_get(struct bitvec *bv, unsigned n)
int16_t x = bitvec_get_int16_msb(bv, n);
uint8_t tmp[2];
osmo_store16be(x, &tmp);
- printf(" -> %d (%u bit) ["BIN_PATTERN" "BIN_PATTERN"]:\n", x, n, BIN(tmp[0]), BIN(tmp[1]));
+ printf(" -> %d (%u bit) ["OSMO_BIN_SPEC" "OSMO_BIN_SPEC"]:\n", x, n, OSMO_BIN_PRINT(tmp[0]), OSMO_BIN_PRINT(tmp[1]));
bitvec_to_string_r(bv, lol);
printf("%s [%d]\n", lol, bv->cur_bit);
}