From 99095773aa31bf8eb283d6f6319a29c71e51ca9c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 4 Aug 2023 13:23:44 -0700 Subject: Woo! Unit Tests! Found some bugs! --- src/unstable/blob.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/unstable') diff --git a/src/unstable/blob.cpp b/src/unstable/blob.cpp index 13209e0..a9cb99d 100644 --- a/src/unstable/blob.cpp +++ b/src/unstable/blob.cpp @@ -236,16 +236,21 @@ bool Bu::Blob::operator!=( const char *pRhs ) const if( pData == pRhs ) return false; - for( int32_t j = 0; j < iSize && pRhs[j]; j++ ) + int32_t j; + for( j = 0; j < iSize && pRhs[j]; j++ ) { if( pData[j] != pRhs[j] ) + { return true; + } } - if( pRhs[iSize] == '\0' ) - return false; + if( !(iSize == j && pRhs[j] == '\0') ) + { + return true; + } - return true; + return false; } bool Bu::Blob::operator<( const Bu::Blob &rRhs ) const @@ -342,7 +347,7 @@ bool Bu::Blob::operator>( const char *pRhs ) const return pData[j] > pRhs[j]; } - if( pRhs[iSize] == '\0' && iSize-1 > j ) + if( pRhs[j] == '\0' && iSize-1 > j ) return true; return false; @@ -367,13 +372,14 @@ bool Bu::Blob::operator>=( const char *pRhs ) const if( pData == pRhs ) return true; - for( int32_t j = 0; j < iSize && pRhs[j]; j++ ) + int32_t j; + for( j = 0; j < iSize && pRhs[j]; j++ ) { if( pData[j] != pRhs[j] ) return pData[j] > pRhs[j]; } - if( pRhs[iSize] == '\0' ) + if( pRhs[j] == '\0' ) return true; return true; -- cgit v1.2.3