Coverage Report

Created: 2026-10-31 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/src/util/Assert.cpp
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
7
 *
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.
12
 *
13
 **********************************************************************/
14
15
#include <string>
16
17
#include <geos/util/Assert.h>
18
#include <geos/util/AssertionFailedException.h>
19
#include <geos/geom/Coordinate.h>
20
21
using std::string;
22
using namespace geos::geom;
23
24
namespace geos {
25
namespace util { // geos.util
26
27
void
28
Assert::isTrue(bool assertion, const std::string& message)
29
16.2M
{
30
16.2M
    if(!assertion) {
31
5.20k
        if(message.empty()) {
32
0
            throw  AssertionFailedException();
33
0
        }
34
5.20k
        else {
35
5.20k
            throw  AssertionFailedException(message);
36
5.20k
        }
37
5.20k
    }
38
16.2M
}
39
40
void
41
Assert::equals(const CoordinateXY& expectedValue,
42
               const CoordinateXY& actualValue, const std::string& message)
43
0
{
44
0
    if(!(actualValue == expectedValue)) {
45
0
        throw  AssertionFailedException("Expected " + expectedValue.toString() + " but encountered "
46
0
                                        + actualValue.toString() + (!message.empty() ? ": " + message : ""));
47
0
    }
48
0
}
49
50
51
void
52
Assert::shouldNeverReachHere(const std::string& message)
53
730
{
54
730
    throw  AssertionFailedException("Should never reach here"
55
730
                                    + (!message.empty() ? ": " + message : ""));
56
730
}
57
58
} // namespace geos.util
59
} // namespace geos