explodethosebits 0.3.0__cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. etb/__init__.py +351 -0
  2. etb/__init__.pyi +976 -0
  3. etb/_etb.cpython-39-x86_64-linux-gnu.so +0 -0
  4. etb/_version.py +34 -0
  5. etb/py.typed +2 -0
  6. explodethosebits-0.3.0.dist-info/METADATA +405 -0
  7. explodethosebits-0.3.0.dist-info/RECORD +88 -0
  8. explodethosebits-0.3.0.dist-info/WHEEL +6 -0
  9. explodethosebits-0.3.0.dist-info/licenses/LICENSE +21 -0
  10. explodethosebits-0.3.0.dist-info/sboms/auditwheel.cdx.json +1 -0
  11. explodethosebits.libs/libcudart-c3a75b33.so.12.8.90 +0 -0
  12. include/etb/bit_coordinate.hpp +45 -0
  13. include/etb/bit_extraction.hpp +79 -0
  14. include/etb/bit_pruning.hpp +122 -0
  15. include/etb/config.hpp +284 -0
  16. include/etb/cuda/arch_optimizations.cuh +358 -0
  17. include/etb/cuda/blackwell_optimizations.cuh +300 -0
  18. include/etb/cuda/cuda_common.cuh +265 -0
  19. include/etb/cuda/etb_cuda.cuh +200 -0
  20. include/etb/cuda/gpu_memory.cuh +406 -0
  21. include/etb/cuda/heuristics_kernel.cuh +315 -0
  22. include/etb/cuda/path_generator_kernel.cuh +272 -0
  23. include/etb/cuda/prefix_pruner_kernel.cuh +370 -0
  24. include/etb/cuda/signature_kernel.cuh +328 -0
  25. include/etb/early_stopping.hpp +246 -0
  26. include/etb/etb.hpp +20 -0
  27. include/etb/heuristics.hpp +165 -0
  28. include/etb/memoization.hpp +285 -0
  29. include/etb/path.hpp +86 -0
  30. include/etb/path_count.hpp +87 -0
  31. include/etb/path_generator.hpp +175 -0
  32. include/etb/prefix_trie.hpp +339 -0
  33. include/etb/reporting.hpp +437 -0
  34. include/etb/scoring.hpp +269 -0
  35. include/etb/signature.hpp +190 -0
  36. include/gmock/gmock-actions.h +2297 -0
  37. include/gmock/gmock-cardinalities.h +159 -0
  38. include/gmock/gmock-function-mocker.h +518 -0
  39. include/gmock/gmock-matchers.h +5623 -0
  40. include/gmock/gmock-more-actions.h +658 -0
  41. include/gmock/gmock-more-matchers.h +120 -0
  42. include/gmock/gmock-nice-strict.h +277 -0
  43. include/gmock/gmock-spec-builders.h +2148 -0
  44. include/gmock/gmock.h +96 -0
  45. include/gmock/internal/custom/README.md +18 -0
  46. include/gmock/internal/custom/gmock-generated-actions.h +7 -0
  47. include/gmock/internal/custom/gmock-matchers.h +37 -0
  48. include/gmock/internal/custom/gmock-port.h +40 -0
  49. include/gmock/internal/gmock-internal-utils.h +487 -0
  50. include/gmock/internal/gmock-port.h +139 -0
  51. include/gmock/internal/gmock-pp.h +279 -0
  52. include/gtest/gtest-assertion-result.h +237 -0
  53. include/gtest/gtest-death-test.h +345 -0
  54. include/gtest/gtest-matchers.h +923 -0
  55. include/gtest/gtest-message.h +252 -0
  56. include/gtest/gtest-param-test.h +546 -0
  57. include/gtest/gtest-printers.h +1161 -0
  58. include/gtest/gtest-spi.h +250 -0
  59. include/gtest/gtest-test-part.h +192 -0
  60. include/gtest/gtest-typed-test.h +331 -0
  61. include/gtest/gtest.h +2321 -0
  62. include/gtest/gtest_pred_impl.h +279 -0
  63. include/gtest/gtest_prod.h +60 -0
  64. include/gtest/internal/custom/README.md +44 -0
  65. include/gtest/internal/custom/gtest-port.h +37 -0
  66. include/gtest/internal/custom/gtest-printers.h +42 -0
  67. include/gtest/internal/custom/gtest.h +37 -0
  68. include/gtest/internal/gtest-death-test-internal.h +307 -0
  69. include/gtest/internal/gtest-filepath.h +227 -0
  70. include/gtest/internal/gtest-internal.h +1560 -0
  71. include/gtest/internal/gtest-param-util.h +1026 -0
  72. include/gtest/internal/gtest-port-arch.h +122 -0
  73. include/gtest/internal/gtest-port.h +2481 -0
  74. include/gtest/internal/gtest-string.h +178 -0
  75. include/gtest/internal/gtest-type-util.h +220 -0
  76. lib/libetb_core.a +0 -0
  77. lib64/cmake/GTest/GTestConfig.cmake +33 -0
  78. lib64/cmake/GTest/GTestConfigVersion.cmake +43 -0
  79. lib64/cmake/GTest/GTestTargets-release.cmake +49 -0
  80. lib64/cmake/GTest/GTestTargets.cmake +139 -0
  81. lib64/libgmock.a +0 -0
  82. lib64/libgmock_main.a +0 -0
  83. lib64/libgtest.a +0 -0
  84. lib64/libgtest_main.a +0 -0
  85. lib64/pkgconfig/gmock.pc +10 -0
  86. lib64/pkgconfig/gmock_main.pc +10 -0
  87. lib64/pkgconfig/gtest.pc +9 -0
  88. lib64/pkgconfig/gtest_main.pc +10 -0
@@ -0,0 +1,307 @@
1
+ // Copyright 2005, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ // The Google C++ Testing and Mocking Framework (Google Test)
31
+ //
32
+ // This header file defines internal utilities needed for implementing
33
+ // death tests. They are subject to change without notice.
34
+
35
+ // IWYU pragma: private, include "gtest/gtest.h"
36
+ // IWYU pragma: friend gtest/.*
37
+ // IWYU pragma: friend gmock/.*
38
+
39
+ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
40
+ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
41
+
42
+ #include <stdio.h>
43
+
44
+ #include <memory>
45
+ #include <string>
46
+
47
+ #include "gtest/gtest-matchers.h"
48
+ #include "gtest/internal/gtest-internal.h"
49
+
50
+ GTEST_DECLARE_string_(internal_run_death_test);
51
+
52
+ namespace testing {
53
+ namespace internal {
54
+
55
+ // Names of the flags (needed for parsing Google Test flags).
56
+ const char kDeathTestStyleFlag[] = "death_test_style";
57
+ const char kDeathTestUseFork[] = "death_test_use_fork";
58
+ const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
59
+
60
+ #ifdef GTEST_HAS_DEATH_TEST
61
+
62
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
63
+ /* class A needs to have dll-interface to be used by clients of class B */)
64
+
65
+ // DeathTest is a class that hides much of the complexity of the
66
+ // GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
67
+ // returns a concrete class that depends on the prevailing death test
68
+ // style, as defined by the --gtest_death_test_style and/or
69
+ // --gtest_internal_run_death_test flags.
70
+
71
+ // In describing the results of death tests, these terms are used with
72
+ // the corresponding definitions:
73
+ //
74
+ // exit status: The integer exit information in the format specified
75
+ // by wait(2)
76
+ // exit code: The integer code passed to exit(3), _exit(2), or
77
+ // returned from main()
78
+ class GTEST_API_ DeathTest {
79
+ public:
80
+ // Create returns false if there was an error determining the
81
+ // appropriate action to take for the current death test; for example,
82
+ // if the gtest_death_test_style flag is set to an invalid value.
83
+ // The LastMessage method will return a more detailed message in that
84
+ // case. Otherwise, the DeathTest pointer pointed to by the "test"
85
+ // argument is set. If the death test should be skipped, the pointer
86
+ // is set to NULL; otherwise, it is set to the address of a new concrete
87
+ // DeathTest object that controls the execution of the current test.
88
+ static bool Create(const char* statement, Matcher<const std::string&> matcher,
89
+ const char* file, int line, DeathTest** test);
90
+ DeathTest();
91
+ virtual ~DeathTest() = default;
92
+
93
+ // A helper class that aborts a death test when it's deleted.
94
+ class ReturnSentinel {
95
+ public:
96
+ explicit ReturnSentinel(DeathTest* test) : test_(test) {}
97
+ ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
98
+
99
+ private:
100
+ DeathTest* const test_;
101
+ ReturnSentinel(const ReturnSentinel&) = delete;
102
+ ReturnSentinel& operator=(const ReturnSentinel&) = delete;
103
+ };
104
+
105
+ // An enumeration of possible roles that may be taken when a death
106
+ // test is encountered. EXECUTE means that the death test logic should
107
+ // be executed immediately. OVERSEE means that the program should prepare
108
+ // the appropriate environment for a child process to execute the death
109
+ // test, then wait for it to complete.
110
+ enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
111
+
112
+ // An enumeration of the three reasons that a test might be aborted.
113
+ enum AbortReason {
114
+ TEST_ENCOUNTERED_RETURN_STATEMENT,
115
+ TEST_THREW_EXCEPTION,
116
+ TEST_DID_NOT_DIE
117
+ };
118
+
119
+ // Assumes one of the above roles.
120
+ virtual TestRole AssumeRole() = 0;
121
+
122
+ // Waits for the death test to finish and returns its status.
123
+ virtual int Wait() = 0;
124
+
125
+ // Returns true if the death test passed; that is, the test process
126
+ // exited during the test, its exit status matches a user-supplied
127
+ // predicate, and its stderr output matches a user-supplied regular
128
+ // expression.
129
+ // The user-supplied predicate may be a macro expression rather
130
+ // than a function pointer or functor, or else Wait and Passed could
131
+ // be combined.
132
+ virtual bool Passed(bool exit_status_ok) = 0;
133
+
134
+ // Signals that the death test did not die as expected.
135
+ virtual void Abort(AbortReason reason) = 0;
136
+
137
+ // Returns a human-readable outcome message regarding the outcome of
138
+ // the last death test.
139
+ static const char* LastMessage();
140
+
141
+ static void set_last_death_test_message(const std::string& message);
142
+
143
+ private:
144
+ // A string containing a description of the outcome of the last death test.
145
+ static std::string last_death_test_message_;
146
+
147
+ DeathTest(const DeathTest&) = delete;
148
+ DeathTest& operator=(const DeathTest&) = delete;
149
+ };
150
+
151
+ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
152
+
153
+ // Factory interface for death tests. May be mocked out for testing.
154
+ class DeathTestFactory {
155
+ public:
156
+ virtual ~DeathTestFactory() = default;
157
+ virtual bool Create(const char* statement,
158
+ Matcher<const std::string&> matcher, const char* file,
159
+ int line, DeathTest** test) = 0;
160
+ };
161
+
162
+ // A concrete DeathTestFactory implementation for normal use.
163
+ class DefaultDeathTestFactory : public DeathTestFactory {
164
+ public:
165
+ bool Create(const char* statement, Matcher<const std::string&> matcher,
166
+ const char* file, int line, DeathTest** test) override;
167
+ };
168
+
169
+ // Returns true if exit_status describes a process that was terminated
170
+ // by a signal, or exited normally with a nonzero exit code.
171
+ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
172
+
173
+ // A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
174
+ // and interpreted as a regex (rather than an Eq matcher) for legacy
175
+ // compatibility.
176
+ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
177
+ ::testing::internal::RE regex) {
178
+ return ContainsRegex(regex.pattern());
179
+ }
180
+ inline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
181
+ return ContainsRegex(regex);
182
+ }
183
+ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
184
+ const ::std::string& regex) {
185
+ return ContainsRegex(regex);
186
+ }
187
+
188
+ // If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
189
+ // used directly.
190
+ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
191
+ Matcher<const ::std::string&> matcher) {
192
+ return matcher;
193
+ }
194
+
195
+ // Traps C++ exceptions escaping statement and reports them as test
196
+ // failures. Note that trapping SEH exceptions is not implemented here.
197
+ #if GTEST_HAS_EXCEPTIONS
198
+ #define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
199
+ try { \
200
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
201
+ } catch (const ::std::exception& gtest_exception) { \
202
+ fprintf( \
203
+ stderr, \
204
+ "\n%s: Caught std::exception-derived exception escaping the " \
205
+ "death test statement. Exception message: %s\n", \
206
+ ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
207
+ gtest_exception.what()); \
208
+ fflush(stderr); \
209
+ death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
210
+ } catch (...) { \
211
+ death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
212
+ }
213
+
214
+ #else
215
+ #define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
216
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
217
+
218
+ #endif
219
+
220
+ // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
221
+ // ASSERT_EXIT*, and EXPECT_EXIT*.
222
+ #define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail) \
223
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
224
+ if (::testing::internal::AlwaysTrue()) { \
225
+ ::testing::internal::DeathTest* gtest_dt; \
226
+ if (!::testing::internal::DeathTest::Create( \
227
+ #statement, \
228
+ ::testing::internal::MakeDeathTestMatcher(regex_or_matcher), \
229
+ __FILE__, __LINE__, &gtest_dt)) { \
230
+ goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
231
+ } \
232
+ if (gtest_dt != nullptr) { \
233
+ std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
234
+ switch (gtest_dt->AssumeRole()) { \
235
+ case ::testing::internal::DeathTest::OVERSEE_TEST: \
236
+ if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
237
+ goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
238
+ } \
239
+ break; \
240
+ case ::testing::internal::DeathTest::EXECUTE_TEST: { \
241
+ const ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
242
+ gtest_dt); \
243
+ GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
244
+ gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
245
+ break; \
246
+ } \
247
+ } \
248
+ } \
249
+ } else \
250
+ GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__) \
251
+ : fail(::testing::internal::DeathTest::LastMessage())
252
+ // The symbol "fail" here expands to something into which a message
253
+ // can be streamed.
254
+
255
+ // This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
256
+ // NDEBUG mode. In this case we need the statements to be executed and the macro
257
+ // must accept a streamed message even though the message is never printed.
258
+ // The regex object is not evaluated, but it is used to prevent "unused"
259
+ // warnings and to avoid an expression that doesn't compile in debug mode.
260
+ #define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher) \
261
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
262
+ if (::testing::internal::AlwaysTrue()) { \
263
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
264
+ } else if (!::testing::internal::AlwaysTrue()) { \
265
+ ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
266
+ } else \
267
+ ::testing::Message()
268
+
269
+ // A class representing the parsed contents of the
270
+ // --gtest_internal_run_death_test flag, as it existed when
271
+ // RUN_ALL_TESTS was called.
272
+ class InternalRunDeathTestFlag {
273
+ public:
274
+ InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index,
275
+ int a_write_fd)
276
+ : file_(a_file), line_(a_line), index_(an_index), write_fd_(a_write_fd) {}
277
+
278
+ ~InternalRunDeathTestFlag() {
279
+ if (write_fd_ >= 0) posix::Close(write_fd_);
280
+ }
281
+
282
+ const std::string& file() const { return file_; }
283
+ int line() const { return line_; }
284
+ int index() const { return index_; }
285
+ int write_fd() const { return write_fd_; }
286
+
287
+ private:
288
+ std::string file_;
289
+ int line_;
290
+ int index_;
291
+ int write_fd_;
292
+
293
+ InternalRunDeathTestFlag(const InternalRunDeathTestFlag&) = delete;
294
+ InternalRunDeathTestFlag& operator=(const InternalRunDeathTestFlag&) = delete;
295
+ };
296
+
297
+ // Returns a newly created InternalRunDeathTestFlag object with fields
298
+ // initialized from the GTEST_FLAG(internal_run_death_test) flag if
299
+ // the flag is specified; otherwise returns NULL.
300
+ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
301
+
302
+ #endif // GTEST_HAS_DEATH_TEST
303
+
304
+ } // namespace internal
305
+ } // namespace testing
306
+
307
+ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
@@ -0,0 +1,227 @@
1
+ // Copyright 2008, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ // Google Test filepath utilities
31
+ //
32
+ // This header file declares classes and functions used internally by
33
+ // Google Test. They are subject to change without notice.
34
+ //
35
+ // This file is #included in gtest/internal/gtest-internal.h.
36
+ // Do not include this header file separately!
37
+
38
+ // IWYU pragma: private, include "gtest/gtest.h"
39
+ // IWYU pragma: friend gtest/.*
40
+ // IWYU pragma: friend gmock/.*
41
+
42
+ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
43
+ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
44
+
45
+ #include <string>
46
+
47
+ #include "gtest/internal/gtest-port.h"
48
+ #include "gtest/internal/gtest-string.h"
49
+
50
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
51
+ /* class A needs to have dll-interface to be used by clients of class B */)
52
+
53
+ #if GTEST_HAS_FILE_SYSTEM
54
+
55
+ namespace testing {
56
+ namespace internal {
57
+
58
+ // FilePath - a class for file and directory pathname manipulation which
59
+ // handles platform-specific conventions (like the pathname separator).
60
+ // Used for helper functions for naming files in a directory for xml output.
61
+ // Except for Set methods, all methods are const or static, which provides an
62
+ // "immutable value object" -- useful for peace of mind.
63
+ // A FilePath with a value ending in a path separator ("like/this/") represents
64
+ // a directory, otherwise it is assumed to represent a file. In either case,
65
+ // it may or may not represent an actual file or directory in the file system.
66
+ // Names are NOT checked for syntax correctness -- no checking for illegal
67
+ // characters, malformed paths, etc.
68
+
69
+ class GTEST_API_ FilePath {
70
+ public:
71
+ FilePath() : pathname_("") {}
72
+ FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
73
+
74
+ explicit FilePath(const std::string& pathname) : pathname_(pathname) {
75
+ Normalize();
76
+ }
77
+
78
+ FilePath& operator=(const FilePath& rhs) {
79
+ Set(rhs);
80
+ return *this;
81
+ }
82
+
83
+ void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
84
+
85
+ const std::string& string() const { return pathname_; }
86
+ const char* c_str() const { return pathname_.c_str(); }
87
+
88
+ // Returns the current working directory, or "" if unsuccessful.
89
+ static FilePath GetCurrentDir();
90
+
91
+ // Given directory = "dir", base_name = "test", number = 0,
92
+ // extension = "xml", returns "dir/test.xml". If number is greater
93
+ // than zero (e.g., 12), returns "dir/test_12.xml".
94
+ // On Windows platform, uses \ as the separator rather than /.
95
+ static FilePath MakeFileName(const FilePath& directory,
96
+ const FilePath& base_name, int number,
97
+ const char* extension);
98
+
99
+ // Given directory = "dir", relative_path = "test.xml",
100
+ // returns "dir/test.xml".
101
+ // On Windows, uses \ as the separator rather than /.
102
+ static FilePath ConcatPaths(const FilePath& directory,
103
+ const FilePath& relative_path);
104
+
105
+ // Returns a pathname for a file that does not currently exist. The pathname
106
+ // will be directory/base_name.extension or
107
+ // directory/base_name_<number>.extension if directory/base_name.extension
108
+ // already exists. The number will be incremented until a pathname is found
109
+ // that does not already exist.
110
+ // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
111
+ // There could be a race condition if two or more processes are calling this
112
+ // function at the same time -- they could both pick the same filename.
113
+ static FilePath GenerateUniqueFileName(const FilePath& directory,
114
+ const FilePath& base_name,
115
+ const char* extension);
116
+
117
+ // Returns true if and only if the path is "".
118
+ bool IsEmpty() const { return pathname_.empty(); }
119
+
120
+ // If input name has a trailing separator character, removes it and returns
121
+ // the name, otherwise return the name string unmodified.
122
+ // On Windows platform, uses \ as the separator, other platforms use /.
123
+ FilePath RemoveTrailingPathSeparator() const;
124
+
125
+ // Returns a copy of the FilePath with the directory part removed.
126
+ // Example: FilePath("path/to/file").RemoveDirectoryName() returns
127
+ // FilePath("file"). If there is no directory part ("just_a_file"), it returns
128
+ // the FilePath unmodified. If there is no file part ("just_a_dir/") it
129
+ // returns an empty FilePath ("").
130
+ // On Windows platform, '\' is the path separator, otherwise it is '/'.
131
+ FilePath RemoveDirectoryName() const;
132
+
133
+ // RemoveFileName returns the directory path with the filename removed.
134
+ // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
135
+ // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
136
+ // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
137
+ // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
138
+ // On Windows platform, '\' is the path separator, otherwise it is '/'.
139
+ FilePath RemoveFileName() const;
140
+
141
+ // Returns a copy of the FilePath with the case-insensitive extension removed.
142
+ // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
143
+ // FilePath("dir/file"). If a case-insensitive extension is not
144
+ // found, returns a copy of the original FilePath.
145
+ FilePath RemoveExtension(const char* extension) const;
146
+
147
+ // Creates directories so that path exists. Returns true if successful or if
148
+ // the directories already exist; returns false if unable to create
149
+ // directories for any reason. Will also return false if the FilePath does
150
+ // not represent a directory (that is, it doesn't end with a path separator).
151
+ bool CreateDirectoriesRecursively() const;
152
+
153
+ // Create the directory so that path exists. Returns true if successful or
154
+ // if the directory already exists; returns false if unable to create the
155
+ // directory for any reason, including if the parent directory does not
156
+ // exist. Not named "CreateDirectory" because that's a macro on Windows.
157
+ bool CreateFolder() const;
158
+
159
+ // Returns true if FilePath describes something in the file-system,
160
+ // either a file, directory, or whatever, and that something exists.
161
+ bool FileOrDirectoryExists() const;
162
+
163
+ // Returns true if pathname describes a directory in the file-system
164
+ // that exists.
165
+ bool DirectoryExists() const;
166
+
167
+ // Returns true if FilePath ends with a path separator, which indicates that
168
+ // it is intended to represent a directory. Returns false otherwise.
169
+ // This does NOT check that a directory (or file) actually exists.
170
+ bool IsDirectory() const;
171
+
172
+ // Returns true if pathname describes a root directory. (Windows has one
173
+ // root directory per disk drive.)
174
+ bool IsRootDirectory() const;
175
+
176
+ // Returns true if pathname describes an absolute path.
177
+ bool IsAbsolutePath() const;
178
+
179
+ private:
180
+ // Replaces multiple consecutive separators with a single separator.
181
+ // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
182
+ // redundancies that might be in a pathname involving "." or "..".
183
+ //
184
+ // A pathname with multiple consecutive separators may occur either through
185
+ // user error or as a result of some scripts or APIs that generate a pathname
186
+ // with a trailing separator. On other platforms the same API or script
187
+ // may NOT generate a pathname with a trailing "/". Then elsewhere that
188
+ // pathname may have another "/" and pathname components added to it,
189
+ // without checking for the separator already being there.
190
+ // The script language and operating system may allow paths like "foo//bar"
191
+ // but some of the functions in FilePath will not handle that correctly. In
192
+ // particular, RemoveTrailingPathSeparator() only removes one separator, and
193
+ // it is called in CreateDirectoriesRecursively() assuming that it will change
194
+ // a pathname from directory syntax (trailing separator) to filename syntax.
195
+ //
196
+ // On Windows this method also replaces the alternate path separator '/' with
197
+ // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
198
+ // "bar\\foo".
199
+
200
+ void Normalize();
201
+
202
+ // Returns a pointer to the last occurrence of a valid path separator in
203
+ // the FilePath. On Windows, for example, both '/' and '\' are valid path
204
+ // separators. Returns NULL if no path separator was found.
205
+ const char* FindLastPathSeparator() const;
206
+
207
+ // Returns the length of the path root, including the directory separator at
208
+ // the end of the prefix. Returns zero by definition if the path is relative.
209
+ // Examples:
210
+ // - [Windows] "..\Sibling" => 0
211
+ // - [Windows] "\Windows" => 1
212
+ // - [Windows] "C:/Windows\Notepad.exe" => 3
213
+ // - [Windows] "\\Host\Share\C$/Windows" => 13
214
+ // - [UNIX] "/bin" => 1
215
+ size_t CalculateRootLength() const;
216
+
217
+ std::string pathname_;
218
+ }; // class FilePath
219
+
220
+ } // namespace internal
221
+ } // namespace testing
222
+
223
+ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
224
+
225
+ #endif // GTEST_HAS_FILE_SYSTEM
226
+
227
+ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_