cppjieba_rb 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +21 -0
  3. data/.github/workflows/linting.yml +30 -0
  4. data/.github/workflows/release.yml +42 -0
  5. data/.github/workflows/tests.yml +47 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +45 -0
  8. data/.ruby-version +1 -0
  9. data/.yamllint +35 -0
  10. data/CHANGELOG.md +17 -0
  11. data/Gemfile +11 -0
  12. data/README.md +5 -5
  13. data/Rakefile +16 -7
  14. data/cppjieba_rb.gemspec +46 -33
  15. data/ext/cppjieba/.github/workflows/cmake.yml +52 -0
  16. data/ext/cppjieba/.github/workflows/stale-issues.yml +24 -0
  17. data/ext/cppjieba/.gitmodules +3 -0
  18. data/ext/cppjieba/{ChangeLog.md → CHANGELOG.md} +50 -1
  19. data/ext/cppjieba/CMakeLists.txt +11 -14
  20. data/ext/cppjieba/LICENSE +20 -0
  21. data/ext/cppjieba/README.md +9 -18
  22. data/ext/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
  23. data/ext/cppjieba/deps/limonp/.gitignore +9 -0
  24. data/ext/cppjieba/deps/limonp/CHANGELOG.md +160 -0
  25. data/ext/cppjieba/deps/limonp/CMakeLists.txt +61 -0
  26. data/ext/cppjieba/deps/limonp/LICENSE +20 -0
  27. data/ext/cppjieba/deps/limonp/README.md +38 -0
  28. data/ext/cppjieba/deps/limonp/{LocalVector.hpp → include/limonp/LocalVector.hpp} +3 -3
  29. data/ext/cppjieba/deps/limonp/{Logging.hpp → include/limonp/Logging.hpp} +17 -3
  30. data/ext/cppjieba/deps/limonp/{StringUtil.hpp → include/limonp/StringUtil.hpp} +31 -10
  31. data/ext/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
  32. data/ext/cppjieba/deps/limonp/test/demo.cpp +40 -0
  33. data/ext/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
  34. data/ext/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
  35. data/ext/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
  36. data/ext/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
  37. data/ext/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
  38. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
  39. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
  40. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
  41. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
  42. data/ext/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
  43. data/ext/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
  44. data/ext/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
  45. data/ext/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
  46. data/ext/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
  47. data/ext/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
  48. data/ext/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
  49. data/ext/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
  50. data/ext/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
  51. data/ext/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
  52. data/ext/cppjieba/include/cppjieba/DictTrie.hpp +9 -0
  53. data/ext/cppjieba/include/cppjieba/Jieba.hpp +4 -0
  54. data/ext/cppjieba/include/cppjieba/Trie.hpp +27 -1
  55. data/ext/cppjieba/test/CMakeLists.txt +4 -3
  56. data/ext/cppjieba/test/unittest/CMakeLists.txt +16 -7
  57. data/ext/cppjieba_rb/extconf.rb +11 -6
  58. data/lib/cppjieba_rb/segment.rb +4 -1
  59. data/lib/cppjieba_rb/version.rb +3 -1
  60. data/lib/cppjieba_rb.rb +12 -5
  61. data/test/test_keyword.rb +8 -8
  62. data/test/test_segment.rb +14 -10
  63. data/test/test_stop_word_filter.rb +5 -3
  64. data/test/test_tagging.rb +5 -2
  65. metadata +63 -140
  66. data/.travis.yml +0 -30
  67. data/ext/cppjieba/.travis.yml +0 -21
  68. data/ext/cppjieba/README_EN.md +0 -115
  69. data/ext/cppjieba/appveyor.yml +0 -32
  70. data/ext/cppjieba/deps/CMakeLists.txt +0 -1
  71. data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
  72. data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
  73. data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
  74. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
  75. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
  76. data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
  77. data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
  78. data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
  79. data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
  80. data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
  81. data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
  82. data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
  83. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
  84. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
  85. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
  86. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
  87. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
  88. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
  89. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
  90. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
  91. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
  92. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
  93. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
  94. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
  95. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
  96. data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
  97. data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
  98. data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
  99. data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
  100. data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
  101. data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
  102. data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
  103. data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
  104. data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
  105. data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
  106. data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
  107. data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
  108. data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
  109. data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
  110. data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
  111. data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
  112. data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
  113. data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
  114. data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
  115. data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
  116. data/ext/cppjieba/test/demo.cpp +0 -80
  117. /data/ext/cppjieba/deps/{gtest/src/.deps/.dirstamp → limonp/.gitmodules} +0 -0
  118. /data/ext/cppjieba/deps/limonp/{ArgvContext.hpp → include/limonp/ArgvContext.hpp} +0 -0
  119. /data/ext/cppjieba/deps/limonp/{Closure.hpp → include/limonp/Closure.hpp} +0 -0
  120. /data/ext/cppjieba/deps/limonp/{Colors.hpp → include/limonp/Colors.hpp} +0 -0
  121. /data/ext/cppjieba/deps/limonp/{Condition.hpp → include/limonp/Condition.hpp} +0 -0
  122. /data/ext/cppjieba/deps/limonp/{Config.hpp → include/limonp/Config.hpp} +0 -0
  123. /data/ext/cppjieba/deps/limonp/{ForcePublic.hpp → include/limonp/ForcePublic.hpp} +0 -0
  124. /data/ext/cppjieba/deps/limonp/{NonCopyable.hpp → include/limonp/NonCopyable.hpp} +0 -0
  125. /data/ext/cppjieba/deps/limonp/{StdExtension.hpp → include/limonp/StdExtension.hpp} +0 -0
  126. /data/ext/cppjieba/deps/{gtest/src/gtest_main.cc → limonp/test/unittest/gtest_main.cpp} +0 -0
@@ -1,308 +0,0 @@
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
- // Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
31
- //
32
- // The Google C++ Testing Framework (Google Test)
33
- //
34
- // This header file defines internal utilities needed for implementing
35
- // death tests. They are subject to change without notice.
36
-
37
- #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
38
- #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
39
-
40
- #include "gtest/internal/gtest-internal.h"
41
-
42
- #include <stdio.h>
43
-
44
- namespace testing {
45
- namespace internal {
46
-
47
- GTEST_DECLARE_string_(internal_run_death_test);
48
-
49
- // Names of the flags (needed for parsing Google Test flags).
50
- const char kDeathTestStyleFlag[] = "death_test_style";
51
- const char kDeathTestUseFork[] = "death_test_use_fork";
52
- const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
53
-
54
- #if GTEST_HAS_DEATH_TEST
55
-
56
- // DeathTest is a class that hides much of the complexity of the
57
- // GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
58
- // returns a concrete class that depends on the prevailing death test
59
- // style, as defined by the --gtest_death_test_style and/or
60
- // --gtest_internal_run_death_test flags.
61
-
62
- // In describing the results of death tests, these terms are used with
63
- // the corresponding definitions:
64
- //
65
- // exit status: The integer exit information in the format specified
66
- // by wait(2)
67
- // exit code: The integer code passed to exit(3), _exit(2), or
68
- // returned from main()
69
- class GTEST_API_ DeathTest {
70
- public:
71
- // Create returns false if there was an error determining the
72
- // appropriate action to take for the current death test; for example,
73
- // if the gtest_death_test_style flag is set to an invalid value.
74
- // The LastMessage method will return a more detailed message in that
75
- // case. Otherwise, the DeathTest pointer pointed to by the "test"
76
- // argument is set. If the death test should be skipped, the pointer
77
- // is set to NULL; otherwise, it is set to the address of a new concrete
78
- // DeathTest object that controls the execution of the current test.
79
- static bool Create(const char* statement, const RE* regex,
80
- const char* file, int line, DeathTest** test);
81
- DeathTest();
82
- virtual ~DeathTest() { }
83
-
84
- // A helper class that aborts a death test when it's deleted.
85
- class ReturnSentinel {
86
- public:
87
- explicit ReturnSentinel(DeathTest* test) : test_(test) { }
88
- ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
89
- private:
90
- DeathTest* const test_;
91
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);
92
- } GTEST_ATTRIBUTE_UNUSED_;
93
-
94
- // An enumeration of possible roles that may be taken when a death
95
- // test is encountered. EXECUTE means that the death test logic should
96
- // be executed immediately. OVERSEE means that the program should prepare
97
- // the appropriate environment for a child process to execute the death
98
- // test, then wait for it to complete.
99
- enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
100
-
101
- // An enumeration of the three reasons that a test might be aborted.
102
- enum AbortReason {
103
- TEST_ENCOUNTERED_RETURN_STATEMENT,
104
- TEST_THREW_EXCEPTION,
105
- TEST_DID_NOT_DIE
106
- };
107
-
108
- // Assumes one of the above roles.
109
- virtual TestRole AssumeRole() = 0;
110
-
111
- // Waits for the death test to finish and returns its status.
112
- virtual int Wait() = 0;
113
-
114
- // Returns true if the death test passed; that is, the test process
115
- // exited during the test, its exit status matches a user-supplied
116
- // predicate, and its stderr output matches a user-supplied regular
117
- // expression.
118
- // The user-supplied predicate may be a macro expression rather
119
- // than a function pointer or functor, or else Wait and Passed could
120
- // be combined.
121
- virtual bool Passed(bool exit_status_ok) = 0;
122
-
123
- // Signals that the death test did not die as expected.
124
- virtual void Abort(AbortReason reason) = 0;
125
-
126
- // Returns a human-readable outcome message regarding the outcome of
127
- // the last death test.
128
- static const char* LastMessage();
129
-
130
- static void set_last_death_test_message(const String& message);
131
-
132
- private:
133
- // A string containing a description of the outcome of the last death test.
134
- static String last_death_test_message_;
135
-
136
- GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
137
- };
138
-
139
- // Factory interface for death tests. May be mocked out for testing.
140
- class DeathTestFactory {
141
- public:
142
- virtual ~DeathTestFactory() { }
143
- virtual bool Create(const char* statement, const RE* regex,
144
- const char* file, int line, DeathTest** test) = 0;
145
- };
146
-
147
- // A concrete DeathTestFactory implementation for normal use.
148
- class DefaultDeathTestFactory : public DeathTestFactory {
149
- public:
150
- virtual bool Create(const char* statement, const RE* regex,
151
- const char* file, int line, DeathTest** test);
152
- };
153
-
154
- // Returns true if exit_status describes a process that was terminated
155
- // by a signal, or exited normally with a nonzero exit code.
156
- GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
157
-
158
- // Traps C++ exceptions escaping statement and reports them as test
159
- // failures. Note that trapping SEH exceptions is not implemented here.
160
- # if GTEST_HAS_EXCEPTIONS
161
- # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
162
- try { \
163
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
164
- } catch (const ::std::exception& gtest_exception) { \
165
- fprintf(\
166
- stderr, \
167
- "\n%s: Caught std::exception-derived exception escaping the " \
168
- "death test statement. Exception message: %s\n", \
169
- ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
170
- gtest_exception.what()); \
171
- fflush(stderr); \
172
- death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
173
- } catch (...) { \
174
- death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
175
- }
176
-
177
- # else
178
- # define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
179
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
180
-
181
- # endif
182
-
183
- // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
184
- // ASSERT_EXIT*, and EXPECT_EXIT*.
185
- # define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
186
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
187
- if (::testing::internal::AlwaysTrue()) { \
188
- const ::testing::internal::RE& gtest_regex = (regex); \
189
- ::testing::internal::DeathTest* gtest_dt; \
190
- if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \
191
- __FILE__, __LINE__, &gtest_dt)) { \
192
- goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
193
- } \
194
- if (gtest_dt != NULL) { \
195
- ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \
196
- gtest_dt_ptr(gtest_dt); \
197
- switch (gtest_dt->AssumeRole()) { \
198
- case ::testing::internal::DeathTest::OVERSEE_TEST: \
199
- if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \
200
- goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \
201
- } \
202
- break; \
203
- case ::testing::internal::DeathTest::EXECUTE_TEST: { \
204
- ::testing::internal::DeathTest::ReturnSentinel \
205
- gtest_sentinel(gtest_dt); \
206
- GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
207
- gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
208
- break; \
209
- } \
210
- default: \
211
- break; \
212
- } \
213
- } \
214
- } else \
215
- GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \
216
- fail(::testing::internal::DeathTest::LastMessage())
217
- // The symbol "fail" here expands to something into which a message
218
- // can be streamed.
219
-
220
- // A class representing the parsed contents of the
221
- // --gtest_internal_run_death_test flag, as it existed when
222
- // RUN_ALL_TESTS was called.
223
- class InternalRunDeathTestFlag {
224
- public:
225
- InternalRunDeathTestFlag(const String& a_file,
226
- int a_line,
227
- int an_index,
228
- int a_write_fd)
229
- : file_(a_file), line_(a_line), index_(an_index),
230
- write_fd_(a_write_fd) {}
231
-
232
- ~InternalRunDeathTestFlag() {
233
- if (write_fd_ >= 0)
234
- posix::Close(write_fd_);
235
- }
236
-
237
- String file() const { return file_; }
238
- int line() const { return line_; }
239
- int index() const { return index_; }
240
- int write_fd() const { return write_fd_; }
241
-
242
- private:
243
- String file_;
244
- int line_;
245
- int index_;
246
- int write_fd_;
247
-
248
- GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
249
- };
250
-
251
- // Returns a newly created InternalRunDeathTestFlag object with fields
252
- // initialized from the GTEST_FLAG(internal_run_death_test) flag if
253
- // the flag is specified; otherwise returns NULL.
254
- InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
255
-
256
- #else // GTEST_HAS_DEATH_TEST
257
-
258
- // This macro is used for implementing macros such as
259
- // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
260
- // death tests are not supported. Those macros must compile on such systems
261
- // iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
262
- // systems that support death tests. This allows one to write such a macro
263
- // on a system that does not support death tests and be sure that it will
264
- // compile on a death-test supporting system.
265
- //
266
- // Parameters:
267
- // statement - A statement that a macro such as EXPECT_DEATH would test
268
- // for program termination. This macro has to make sure this
269
- // statement is compiled but not executed, to ensure that
270
- // EXPECT_DEATH_IF_SUPPORTED compiles with a certain
271
- // parameter iff EXPECT_DEATH compiles with it.
272
- // regex - A regex that a macro such as EXPECT_DEATH would use to test
273
- // the output of statement. This parameter has to be
274
- // compiled but not evaluated by this macro, to ensure that
275
- // this macro only accepts expressions that a macro such as
276
- // EXPECT_DEATH would accept.
277
- // terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED
278
- // and a return statement for ASSERT_DEATH_IF_SUPPORTED.
279
- // This ensures that ASSERT_DEATH_IF_SUPPORTED will not
280
- // compile inside functions where ASSERT_DEATH doesn't
281
- // compile.
282
- //
283
- // The branch that has an always false condition is used to ensure that
284
- // statement and regex are compiled (and thus syntactically correct) but
285
- // never executed. The unreachable code macro protects the terminator
286
- // statement from generating an 'unreachable code' warning in case
287
- // statement unconditionally returns or throws. The Message constructor at
288
- // the end allows the syntax of streaming additional messages into the
289
- // macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.
290
- # define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \
291
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
292
- if (::testing::internal::AlwaysTrue()) { \
293
- GTEST_LOG_(WARNING) \
294
- << "Death tests are not supported on this platform.\n" \
295
- << "Statement '" #statement "' cannot be verified."; \
296
- } else if (::testing::internal::AlwaysFalse()) { \
297
- ::testing::internal::RE::PartialMatch(".*", (regex)); \
298
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
299
- terminator; \
300
- } else \
301
- ::testing::Message()
302
-
303
- #endif // GTEST_HAS_DEATH_TEST
304
-
305
- } // namespace internal
306
- } // namespace testing
307
-
308
- #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
@@ -1,210 +0,0 @@
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
- // Author: keith.ray@gmail.com (Keith Ray)
31
- //
32
- // Google Test filepath utilities
33
- //
34
- // This header file declares classes and functions used internally by
35
- // Google Test. They are subject to change without notice.
36
- //
37
- // This file is #included in <gtest/internal/gtest-internal.h>.
38
- // Do not include this header file separately!
39
-
40
- #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
41
- #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
42
-
43
- #include "gtest/internal/gtest-string.h"
44
-
45
- namespace testing {
46
- namespace internal {
47
-
48
- // FilePath - a class for file and directory pathname manipulation which
49
- // handles platform-specific conventions (like the pathname separator).
50
- // Used for helper functions for naming files in a directory for xml output.
51
- // Except for Set methods, all methods are const or static, which provides an
52
- // "immutable value object" -- useful for peace of mind.
53
- // A FilePath with a value ending in a path separator ("like/this/") represents
54
- // a directory, otherwise it is assumed to represent a file. In either case,
55
- // it may or may not represent an actual file or directory in the file system.
56
- // Names are NOT checked for syntax correctness -- no checking for illegal
57
- // characters, malformed paths, etc.
58
-
59
- class GTEST_API_ FilePath {
60
- public:
61
- FilePath() : pathname_("") { }
62
- FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
63
-
64
- explicit FilePath(const char* pathname) : pathname_(pathname) {
65
- Normalize();
66
- }
67
-
68
- explicit FilePath(const String& pathname) : pathname_(pathname) {
69
- Normalize();
70
- }
71
-
72
- FilePath& operator=(const FilePath& rhs) {
73
- Set(rhs);
74
- return *this;
75
- }
76
-
77
- void Set(const FilePath& rhs) {
78
- pathname_ = rhs.pathname_;
79
- }
80
-
81
- String ToString() const { return pathname_; }
82
- const char* c_str() const { return pathname_.c_str(); }
83
-
84
- // Returns the current working directory, or "" if unsuccessful.
85
- static FilePath GetCurrentDir();
86
-
87
- // Given directory = "dir", base_name = "test", number = 0,
88
- // extension = "xml", returns "dir/test.xml". If number is greater
89
- // than zero (e.g., 12), returns "dir/test_12.xml".
90
- // On Windows platform, uses \ as the separator rather than /.
91
- static FilePath MakeFileName(const FilePath& directory,
92
- const FilePath& base_name,
93
- int number,
94
- const char* extension);
95
-
96
- // Given directory = "dir", relative_path = "test.xml",
97
- // returns "dir/test.xml".
98
- // On Windows, uses \ as the separator rather than /.
99
- static FilePath ConcatPaths(const FilePath& directory,
100
- const FilePath& relative_path);
101
-
102
- // Returns a pathname for a file that does not currently exist. The pathname
103
- // will be directory/base_name.extension or
104
- // directory/base_name_<number>.extension if directory/base_name.extension
105
- // already exists. The number will be incremented until a pathname is found
106
- // that does not already exist.
107
- // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
108
- // There could be a race condition if two or more processes are calling this
109
- // function at the same time -- they could both pick the same filename.
110
- static FilePath GenerateUniqueFileName(const FilePath& directory,
111
- const FilePath& base_name,
112
- const char* extension);
113
-
114
- // Returns true iff the path is NULL or "".
115
- bool IsEmpty() const { return c_str() == NULL || *c_str() == '\0'; }
116
-
117
- // If input name has a trailing separator character, removes it and returns
118
- // the name, otherwise return the name string unmodified.
119
- // On Windows platform, uses \ as the separator, other platforms use /.
120
- FilePath RemoveTrailingPathSeparator() const;
121
-
122
- // Returns a copy of the FilePath with the directory part removed.
123
- // Example: FilePath("path/to/file").RemoveDirectoryName() returns
124
- // FilePath("file"). If there is no directory part ("just_a_file"), it returns
125
- // the FilePath unmodified. If there is no file part ("just_a_dir/") it
126
- // returns an empty FilePath ("").
127
- // On Windows platform, '\' is the path separator, otherwise it is '/'.
128
- FilePath RemoveDirectoryName() const;
129
-
130
- // RemoveFileName returns the directory path with the filename removed.
131
- // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
132
- // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
133
- // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
134
- // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
135
- // On Windows platform, '\' is the path separator, otherwise it is '/'.
136
- FilePath RemoveFileName() const;
137
-
138
- // Returns a copy of the FilePath with the case-insensitive extension removed.
139
- // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
140
- // FilePath("dir/file"). If a case-insensitive extension is not
141
- // found, returns a copy of the original FilePath.
142
- FilePath RemoveExtension(const char* extension) const;
143
-
144
- // Creates directories so that path exists. Returns true if successful or if
145
- // the directories already exist; returns false if unable to create
146
- // directories for any reason. Will also return false if the FilePath does
147
- // not represent a directory (that is, it doesn't end with a path separator).
148
- bool CreateDirectoriesRecursively() const;
149
-
150
- // Create the directory so that path exists. Returns true if successful or
151
- // if the directory already exists; returns false if unable to create the
152
- // directory for any reason, including if the parent directory does not
153
- // exist. Not named "CreateDirectory" because that's a macro on Windows.
154
- bool CreateFolder() const;
155
-
156
- // Returns true if FilePath describes something in the file-system,
157
- // either a file, directory, or whatever, and that something exists.
158
- bool FileOrDirectoryExists() const;
159
-
160
- // Returns true if pathname describes a directory in the file-system
161
- // that exists.
162
- bool DirectoryExists() const;
163
-
164
- // Returns true if FilePath ends with a path separator, which indicates that
165
- // it is intended to represent a directory. Returns false otherwise.
166
- // This does NOT check that a directory (or file) actually exists.
167
- bool IsDirectory() const;
168
-
169
- // Returns true if pathname describes a root directory. (Windows has one
170
- // root directory per disk drive.)
171
- bool IsRootDirectory() const;
172
-
173
- // Returns true if pathname describes an absolute path.
174
- bool IsAbsolutePath() const;
175
-
176
- private:
177
- // Replaces multiple consecutive separators with a single separator.
178
- // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
179
- // redundancies that might be in a pathname involving "." or "..".
180
- //
181
- // A pathname with multiple consecutive separators may occur either through
182
- // user error or as a result of some scripts or APIs that generate a pathname
183
- // with a trailing separator. On other platforms the same API or script
184
- // may NOT generate a pathname with a trailing "/". Then elsewhere that
185
- // pathname may have another "/" and pathname components added to it,
186
- // without checking for the separator already being there.
187
- // The script language and operating system may allow paths like "foo//bar"
188
- // but some of the functions in FilePath will not handle that correctly. In
189
- // particular, RemoveTrailingPathSeparator() only removes one separator, and
190
- // it is called in CreateDirectoriesRecursively() assuming that it will change
191
- // a pathname from directory syntax (trailing separator) to filename syntax.
192
- //
193
- // On Windows this method also replaces the alternate path separator '/' with
194
- // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
195
- // "bar\\foo".
196
-
197
- void Normalize();
198
-
199
- // Returns a pointer to the last occurence of a valid path separator in
200
- // the FilePath. On Windows, for example, both '/' and '\' are valid path
201
- // separators. Returns NULL if no path separator was found.
202
- const char* FindLastPathSeparator() const;
203
-
204
- String pathname_;
205
- }; // class FilePath
206
-
207
- } // namespace internal
208
- } // namespace testing
209
-
210
- #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_