Change bassert to always call assert

This commit is contained in:
Vinnie Falco
2014-02-06 11:38:39 -08:00
parent 572aae320d
commit 9bc6e83f8a
10 changed files with 58 additions and 13 deletions

View File

@@ -1157,9 +1157,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\NameResolver.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\PackedMessage.cpp"> <ClCompile Include="..\..\src\ripple_app\peers\PackedMessage.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -2517,7 +2514,6 @@
<ClInclude Include="..\..\src\ripple_app\paths\RippleCalc.h" /> <ClInclude Include="..\..\src\ripple_app\paths\RippleCalc.h" />
<ClInclude Include="..\..\src\ripple_app\paths\RippleLineCache.h" /> <ClInclude Include="..\..\src\ripple_app\paths\RippleLineCache.h" />
<ClInclude Include="..\..\src\ripple_app\paths\RippleState.h" /> <ClInclude Include="..\..\src\ripple_app\paths\RippleState.h" />
<ClInclude Include="..\..\src\ripple_app\peers\NameResolver.h" />
<ClInclude Include="..\..\src\ripple_app\peers\PackedMessage.h" /> <ClInclude Include="..\..\src\ripple_app\peers\PackedMessage.h" />
<ClInclude Include="..\..\src\ripple_app\peers\PeerDoor.h" /> <ClInclude Include="..\..\src\ripple_app\peers\PeerDoor.h" />
<ClInclude Include="..\..\src\ripple_app\peers\ClusterNodeStatus.h" /> <ClInclude Include="..\..\src\ripple_app\peers\ClusterNodeStatus.h" />

View File

@@ -1371,9 +1371,6 @@
<ClCompile Include="..\..\src\ripple_app\main\CollectorManager.cpp"> <ClCompile Include="..\..\src\ripple_app\main\CollectorManager.cpp">
<Filter>[2] Old Ripple\ripple_app\main</Filter> <Filter>[2] Old Ripple\ripple_app\main</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\NameResolver.cpp">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\shamap\FetchPackTests.cpp"> <ClCompile Include="..\..\src\ripple_app\shamap\FetchPackTests.cpp">
<Filter>[2] Old Ripple\ripple_app\shamap</Filter> <Filter>[2] Old Ripple\ripple_app\shamap</Filter>
</ClCompile> </ClCompile>
@@ -2844,9 +2841,6 @@
<ClInclude Include="..\..\src\ripple_app\main\CollectorManager.h"> <ClInclude Include="..\..\src\ripple_app\main\CollectorManager.h">
<Filter>[2] Old Ripple\ripple_app\main</Filter> <Filter>[2] Old Ripple\ripple_app\main</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\NameResolver.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\shamap\RadixMapTest.h"> <ClInclude Include="..\..\src\ripple_app\shamap\RadixMapTest.h">
<Filter>[2] Old Ripple\ripple_app\shamap</Filter> <Filter>[2] Old Ripple\ripple_app\shamap</Filter>
</ClInclude> </ClInclude>

View File

@@ -657,6 +657,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\beast\threads\Threads.cpp" /> <ClCompile Include="..\..\beast\threads\Threads.cpp" />
<ClCompile Include="..\..\beast\utility\impl\Assert.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\beast\utility\impl\Debug.cpp"> <ClCompile Include="..\..\beast\utility\impl\Debug.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>

View File

@@ -1844,6 +1844,9 @@
<ClCompile Include="..\..\beast\net\impl\IPEndpoint.cpp"> <ClCompile Include="..\..\beast\net\impl\IPEndpoint.cpp">
<Filter>beast\net\impl</Filter> <Filter>beast\net\impl</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\beast\utility\impl\Assert.cpp">
<Filter>beast\utility\impl</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Text Include="..\..\TODO.txt"> <Text Include="..\..\TODO.txt">

View File

@@ -30,6 +30,8 @@
#error "PlatformConfig.h must come first!" #error "PlatformConfig.h must come first!"
#endif #endif
#include <assert.h>
// This file defines miscellaneous macros for debugging, assertions, etc. // This file defines miscellaneous macros for debugging, assertions, etc.
#if BEAST_FORCE_DEBUG #if BEAST_FORCE_DEBUG
@@ -109,6 +111,7 @@ extern void beast_reportFatalError (char const* message, char const* fileName, i
*/ */
#define BDBG(dbgtext) { beast::String tempDbgBuf; tempDbgBuf << dbgtext; beast::Logger::outputDebugString (tempDbgBuf); } #define BDBG(dbgtext) { beast::String tempDbgBuf; tempDbgBuf << dbgtext; beast::Logger::outputDebugString (tempDbgBuf); }
#if 0
/** This will always cause an assertion failure. /** This will always cause an assertion failure.
It is only compiled in a debug build, (unless BEAST_LOG_ASSERTIONS is enabled for your build). It is only compiled in a debug build, (unless BEAST_LOG_ASSERTIONS is enabled for your build).
@see bassert @see bassert
@@ -122,6 +125,11 @@ extern void beast_reportFatalError (char const* message, char const* fileName, i
@see bassertfalse @see bassertfalse
*/ */
#define bassert(expression) { if (! (expression)) beast_reportFatalError(#expression,__FILE__,__LINE__); } #define bassert(expression) { if (! (expression)) beast_reportFatalError(#expression,__FILE__,__LINE__); }
#else
#define bassertfalse assert(false)
#define bassert(expression) assert(expression)
#endif
#else #else

View File

@@ -334,7 +334,7 @@ public:
} }
*lhs++ = UInt (part); *lhs++ = UInt (part);
} }
bassert (carry == 0) // overflow bassert (carry == 0); // overflow
return *this; return *this;
} }

View File

@@ -24,6 +24,7 @@
// For Journal and Debug // For Journal and Debug
#include "../../modules/beast_core/beast_core.h" #include "../../modules/beast_core/beast_core.h"
#include "impl/Assert.cpp"
#include "impl/Debug.cpp" #include "impl/Debug.cpp"
#include "impl/Journal.cpp" #include "impl/Journal.cpp"
#include "impl/LeakChecked.cpp" #include "impl/LeakChecked.cpp"

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
namespace beast {
class BassertUnitTests : public UnitTest
{
public:
void runTest ()
{
beginTestCase ("bassert");
bassert (false);
}
BassertUnitTests () : UnitTest ("bassert", "beast", runManual) { }
};
//------------------------------------------------------------------------------
static BassertUnitTests bassertUnitTests;
}

View File

@@ -393,7 +393,7 @@ void UnitTests::runTests (TestList const& tests, int64 randomSeed)
void UnitTests::onFailure () void UnitTests::onFailure ()
{ {
// A failure occurred and the setting to assert on failures is turned on. // A failure occurred and the setting to assert on failures is turned on.
bassert (! m_assertOnFailure) bassert (! m_assertOnFailure);
} }
bool UnitTests::shouldAbortTests() bool UnitTests::shouldAbortTests()

View File

@@ -47,7 +47,7 @@ XmlElement::XmlElement (const String& tag) noexcept
: tagName (tag) : tagName (tag)
{ {
// the tag name mustn't be empty, or it'll look like a text element! // the tag name mustn't be empty, or it'll look like a text element!
bassert (tag.containsNonWhitespaceChars()) bassert (tag.containsNonWhitespaceChars());
// The tag can't contain spaces or other characters that would create invalid XML! // The tag can't contain spaces or other characters that would create invalid XML!
bassert (! tag.containsAnyOf (" <>/&")); bassert (! tag.containsAnyOf (" <>/&"));