Ranges are equal when they hold the same objects in the same order.
A range compares equal to a range over a copy of its objects, wherever the two are stored, including when one range begins where the other ends.
30 {
31 LOG_UNIT_TEST;
32
33
36
37 std::vector<const Elem *> all(
mesh.elements_begin(),
mesh.elements_end());
38 std::vector<const Elem *> copy(all);
39 std::vector<const Elem *> fewer(all.begin(), all.end() - 1);
40 std::vector<const Elem *> reversed(all.rbegin(), all.rend());
41
42 const ConstElemRange all_range(&all), copy_range(©), fewer_range(&fewer),
43 reversed_range(&reversed);
44
45 CPPUNIT_ASSERT(all_range == copy_range);
46 CPPUNIT_ASSERT(!(all_range == fewer_range));
47 CPPUNIT_ASSERT(!(fewer_range == all_range));
48 CPPUNIT_ASSERT(!(all_range == reversed_range));
49
50
51 std::vector<const Elem *> twice(all);
52 twice.insert(twice.end(), all.begin(), all.end());
54 const auto middle = twice_range.begin() + all.size();
55 const ConstElemRange first_half(twice_range, twice_range.begin(), middle),
56 second_half(twice_range, middle, twice_range.end());
57
58 CPPUNIT_ASSERT(first_half == second_half);
59 CPPUNIT_ASSERT(second_half == first_half);
60 }
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The StoredRange class defines a contiguous, divisible set of objects.