GCC Code Coverage Report


Directory: ./
File: tasks/redkina_a_graham_approach/common/include/common.hpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 1 1 100.0%
Branches: 20 64 31.2%

Line Branch Exec Source
1 #pragma once
2
3 #include <algorithm>
4 #include <tuple>
5 #include <vector>
6
7 #include "task/include/task.hpp"
8
9 namespace redkina_a_graham_approach {
10
11 struct Point {
12 int x{};
13 int y{};
14
15 constexpr bool operator==(const Point &other) const noexcept {
16 return x == other.x && y == other.y;
17 }
18
19 constexpr bool operator!=(const Point &other) const noexcept {
20 return !(*this == other);
21 }
22 };
23
24 constexpr bool ArePointsEqual(const Point &p1, const Point &p2) noexcept {
25
10/32
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 6 times.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 2 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 6 times.
✓ Branch 29 taken 20 times.
✓ Branch 30 taken 6 times.
✗ Branch 31 not taken.
40 return p1.x == p2.x && p1.y == p2.y;
26 }
27
28 constexpr int CalcCross(const Point &p1, const Point &p2, const Point &p3) noexcept {
29
4/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 22 times.
164 return ((p2.x - p1.x) * (p3.y - p1.y)) - ((p2.y - p1.y) * (p3.x - p1.x));
30 }
31
32 constexpr int CalcDistSq(const Point &p1, const Point &p2) noexcept {
33 const int dx = p2.x - p1.x;
34 const int dy = p2.y - p1.y;
35 8 return (dx * dx) + (dy * dy);
36 }
37
38
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 inline Point FindPivotPoint(const std::vector<Point> &points) {
39 return *std::ranges::min_element(
40
5/6
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
28 points, [](const Point &a, const Point &b) { return a.y < b.y || (a.y == b.y && a.x < b.x); });
41 }
42
43 using InType = std::vector<Point>;
44 using OutType = std::vector<Point>;
45 using TestType = std::tuple<int, std::vector<Point>, std::vector<Point>>;
46 using BaseTask = ppc::task::Task<InType, OutType>;
47
48 } // namespace redkina_a_graham_approach
49