Add more asserts to catch bugs.

This commit is contained in:
Jonathan Naylor
2016-03-07 20:21:55 +00:00
parent 14c6208ae5
commit 12fb99c00a
12 changed files with 92 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009,2014,2015 Jonathan Naylor, G4KLX
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -91,6 +91,8 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne
void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
bits[0U] = (byte & 0x80U) == 0x80U;
bits[1U] = (byte & 0x40U) == 0x40U;
bits[2U] = (byte & 0x20U) == 0x20U;
@@ -103,6 +105,8 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
bits[0U] = (byte & 0x01U) == 0x01U;
bits[1U] = (byte & 0x02U) == 0x02U;
bits[2U] = (byte & 0x04U) == 0x04U;
@@ -115,6 +119,8 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
byte = bits[0U] ? 0x80U : 0x00U;
byte |= bits[1U] ? 0x40U : 0x00U;
byte |= bits[2U] ? 0x20U : 0x00U;
@@ -127,6 +133,8 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
byte = bits[0U] ? 0x01U : 0x00U;
byte |= bits[1U] ? 0x02U : 0x00U;
byte |= bits[2U] ? 0x04U : 0x00U;