Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / src / util / Assert.cpp
blobd5949f1d3588a7c3c044f0f1ba00f5331d67e3c5
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************/
15 #include <string>
17 #include <geos/util/Assert.h>
18 #include <geos/util/AssertionFailedException.h>
19 #include <geos/geom/Coordinate.h>
21 using std::string;
22 using namespace geos::geom;
24 namespace geos {
25 namespace util { // geos.util
27 void
28 Assert::isTrue(bool assertion, const string& message)
30 if (!assertion) {
31 if (message.empty()) {
32 throw AssertionFailedException();
33 } else {
34 throw AssertionFailedException(message);
39 void
40 Assert::equals(const Coordinate& expectedValue,
41 const Coordinate& actualValue, const string& message)
43 if (!(actualValue==expectedValue)) {
44 throw AssertionFailedException("Expected " + expectedValue.toString() + " but encountered "
45 + actualValue.toString() + (!message.empty() ? ": " + message : ""));
50 void Assert::shouldNeverReachHere(const string& message) {
51 throw AssertionFailedException("Should never reach here"
52 + (!message.empty() ? ": " + message : ""));
55 } // namespace geos.util
56 } // namespace geos
58 /**********************************************************************
59 * $Log$
60 * Revision 1.14 2006/03/09 16:46:49 strk
61 * geos::geom namespace definition, first pass at headers split
63 * Revision 1.13 2006/03/06 19:40:47 strk
64 * geos::util namespace. New GeometryCollection::iterator interface, many cleanups.
66 * Revision 1.12 2006/03/03 10:46:22 strk
67 * Removed 'using namespace' from headers, added missing headers in .cpp files, removed useless includes in headers (bug#46)
69 * Revision 1.11 2006/02/23 11:54:21 strk
70 * - MCIndexPointSnapper
71 * - MCIndexSnapRounder
72 * - SnapRounding BufferOp
73 * - ScaledNoder
74 * - GEOSException hierarchy cleanups
75 * - SpatialIndex memory-friendly query interface
76 * - GeometryGraph::getBoundaryNodes memory-friendly
77 * - NodeMap::getBoundaryNodes memory-friendly
78 * - Cleanups in geomgraph::Edge
79 * - Added an XML test for snaprounding buffer (shows leaks, working on it)
81 * Revision 1.10 2006/02/09 15:52:47 strk
82 * GEOSException derived from std::exception; always thrown and cought by const ref.
84 * Revision 1.9 2004/07/02 13:28:29 strk
85 * Fixed all #include lines to reflect headers layout change.
86 * Added client application build tips in README.
88 * Revision 1.8 2003/11/07 01:23:43 pramsey
89 * Add standard CVS headers licence notices and copyrights to all cpp and h
90 * files.
93 **********************************************************************/