[PATCH 30/57][Arm][GAS] Add support for MVE instructions: vqmovnt, vqmovnb, vqmovunt...
[binutils-gdb.git] / gdb / unittests / memrange-selftests.c
blobada8e3e43427418eba83643d0c5818b11cbce2bd
1 /* Self tests for mem ranges for GDB, the GNU debugger.
3 Copyright (C) 2017-2019 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "defs.h"
21 #include "common/selftest.h"
22 #include "memrange.h"
24 namespace selftests {
25 namespace memrange_tests {
27 static void
28 normalize_mem_ranges_tests ()
30 /* Empty vector. */
32 std::vector<mem_range> ranges;
34 normalize_mem_ranges (&ranges);
36 SELF_CHECK (ranges.size () == 0);
39 /* With one range. */
41 std::vector<mem_range> ranges;
43 ranges.emplace_back (10, 20);
45 normalize_mem_ranges (&ranges);
47 SELF_CHECK (ranges.size () == 1);
48 SELF_CHECK (ranges[0] == mem_range (10, 20));
51 /* Completely disjoint ranges. */
53 std::vector<mem_range> ranges;
55 ranges.emplace_back (20, 1);
56 ranges.emplace_back (10, 1);
58 normalize_mem_ranges (&ranges);
60 SELF_CHECK (ranges.size () == 2);
61 SELF_CHECK (ranges[0] == mem_range (10, 1));
62 SELF_CHECK (ranges[1] == mem_range (20, 1));
65 /* Overlapping and contiguous ranges. */
67 std::vector<mem_range> ranges;
69 ranges.emplace_back (5, 10);
70 ranges.emplace_back (10, 10);
71 ranges.emplace_back (15, 10);
73 normalize_mem_ranges (&ranges);
75 SELF_CHECK (ranges.size () == 1);
76 SELF_CHECK (ranges[0] == mem_range (5, 20));
79 /* Duplicate ranges. */
81 std::vector<mem_range> ranges;
83 ranges.emplace_back (10, 10);
84 ranges.emplace_back (10, 10);
86 normalize_mem_ranges (&ranges);
88 SELF_CHECK (ranges.size () == 1);
89 SELF_CHECK (ranges[0] == mem_range (10, 10));
92 /* Range completely inside another. */
94 std::vector<mem_range> ranges;
96 ranges.emplace_back (14, 2);
97 ranges.emplace_back (10, 10);
99 normalize_mem_ranges (&ranges);
101 SELF_CHECK (ranges.size () == 1);
102 SELF_CHECK (ranges[0] == mem_range (10, 10));
106 } /* namespace memrange_tests */
107 } /* namespace selftests */
109 void
110 _initialize_memrange_selftests ()
112 selftests::register_test
113 ("normalize_mem_ranges",
114 selftests::memrange_tests::normalize_mem_ranges_tests);