summaryrefslogtreecommitdiff
path: root/testing/range_set.h
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2017-09-28 18:46:03 +0300
committerChromium commit bot <commit-bot@chromium.org>2017-09-28 15:59:08 +0000
commit0e60b9ef2b79de52ef62101abae2af7292e879b7 (patch)
tree9f71519f2a364ee6702219a44de7fdb1def18cc7 /testing/range_set.h
parent1ca7173cd85adcd58766fc89f95c3dc163efa17a (diff)
downloadpdfium-0e60b9ef2b79de52ef62101abae2af7292e879b7.tar.xz
Implement FakeFileAccess.
Update embedder tests to simulate unavailable data and download requests. Change-Id: I634fa89d2a0c859243e849752936da87568909f4 Reviewed-on: https://pdfium-review.googlesource.com/11890 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'testing/range_set.h')
-rw-r--r--testing/range_set.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/testing/range_set.h b/testing/range_set.h
new file mode 100644
index 0000000000..87cbee910b
--- /dev/null
+++ b/testing/range_set.h
@@ -0,0 +1,45 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TESTING_RANGE_SET_H_
+#define TESTING_RANGE_SET_H_
+
+#include <set>
+#include <utility>
+
+class RangeSet {
+ public:
+ using Range = std::pair<size_t, size_t>;
+
+ RangeSet();
+ ~RangeSet();
+
+ bool Contains(const Range& range) const;
+
+ void Union(const Range& range);
+
+ void Union(const RangeSet& range_set);
+
+ bool IsEmpty() const { return ranges().empty(); }
+
+ void Clear() { ranges_.clear(); }
+
+ struct range_compare {
+ bool operator()(const Range& lval, const Range& rval) const {
+ return lval.first < rval.first;
+ }
+ };
+
+ using RangesContainer = std::set<Range, range_compare>;
+ const RangesContainer& ranges() const { return ranges_; }
+
+ private:
+ Range FixDirection(const Range& range) const;
+
+ bool IsEmptyRange(const Range& range) const;
+
+ RangesContainer ranges_;
+};
+
+#endif // TESTING_RANGE_SET_H_