snappy 0.0.17 → 0.4.0

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 (93) hide show
  1. checksums.yaml +5 -5
  2. data/.dockerignore +2 -0
  3. data/.github/workflows/main.yml +34 -0
  4. data/.github/workflows/publish.yml +34 -0
  5. data/.gitignore +2 -1
  6. data/.gitmodules +1 -1
  7. data/Dockerfile +13 -0
  8. data/Gemfile +4 -0
  9. data/README.md +45 -5
  10. data/Rakefile +32 -29
  11. data/ext/api.c +6 -1
  12. data/ext/extconf.rb +31 -22
  13. data/lib/snappy/hadoop/reader.rb +62 -0
  14. data/lib/snappy/hadoop/writer.rb +51 -0
  15. data/lib/snappy/hadoop.rb +22 -0
  16. data/lib/snappy/reader.rb +14 -10
  17. data/lib/snappy/shim.rb +1 -1
  18. data/lib/snappy/version.rb +1 -1
  19. data/lib/snappy.rb +5 -4
  20. data/snappy.gemspec +14 -13
  21. data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
  22. data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
  23. data/test/snappy_hadoop_test.rb +26 -0
  24. data/test/snappy_reader_test.rb +148 -0
  25. data/test/snappy_test.rb +95 -0
  26. data/test/snappy_writer_test.rb +55 -0
  27. data/test/test_helper.rb +7 -0
  28. data/test.sh +3 -0
  29. data/vendor/snappy/CMakeLists.txt +420 -0
  30. data/vendor/snappy/CONTRIBUTING.md +31 -0
  31. data/vendor/snappy/NEWS +52 -0
  32. data/vendor/snappy/{README → README.md} +75 -49
  33. data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
  34. data/vendor/snappy/cmake/config.h.in +66 -0
  35. data/vendor/snappy/docs/README.md +72 -0
  36. data/vendor/snappy/snappy-internal.h +200 -32
  37. data/vendor/snappy/snappy-sinksource.cc +26 -9
  38. data/vendor/snappy/snappy-sinksource.h +11 -11
  39. data/vendor/snappy/snappy-stubs-internal.cc +1 -1
  40. data/vendor/snappy/snappy-stubs-internal.h +299 -302
  41. data/vendor/snappy/snappy-stubs-public.h.in +10 -47
  42. data/vendor/snappy/snappy-test.cc +94 -200
  43. data/vendor/snappy/snappy-test.h +101 -358
  44. data/vendor/snappy/snappy.cc +1437 -474
  45. data/vendor/snappy/snappy.h +31 -12
  46. data/vendor/snappy/snappy_benchmark.cc +378 -0
  47. data/vendor/snappy/snappy_compress_fuzzer.cc +60 -0
  48. data/vendor/snappy/snappy_test_data.cc +57 -0
  49. data/vendor/snappy/snappy_test_data.h +68 -0
  50. data/vendor/snappy/snappy_test_tool.cc +471 -0
  51. data/vendor/snappy/snappy_uncompress_fuzzer.cc +58 -0
  52. data/vendor/snappy/snappy_unittest.cc +271 -792
  53. metadata +42 -92
  54. data/.travis.yml +0 -26
  55. data/smoke.sh +0 -8
  56. data/test/test-snappy-reader.rb +0 -129
  57. data/test/test-snappy-writer.rb +0 -55
  58. data/test/test-snappy.rb +0 -58
  59. data/vendor/snappy/ChangeLog +0 -2468
  60. data/vendor/snappy/INSTALL +0 -370
  61. data/vendor/snappy/Makefile +0 -982
  62. data/vendor/snappy/Makefile.am +0 -26
  63. data/vendor/snappy/Makefile.in +0 -982
  64. data/vendor/snappy/aclocal.m4 +0 -9738
  65. data/vendor/snappy/autogen.sh +0 -12
  66. data/vendor/snappy/autom4te.cache/output.0 +0 -18856
  67. data/vendor/snappy/autom4te.cache/output.1 +0 -18852
  68. data/vendor/snappy/autom4te.cache/requests +0 -297
  69. data/vendor/snappy/autom4te.cache/traces.0 +0 -2689
  70. data/vendor/snappy/autom4te.cache/traces.1 +0 -714
  71. data/vendor/snappy/config.guess +0 -1530
  72. data/vendor/snappy/config.h +0 -135
  73. data/vendor/snappy/config.h.in +0 -134
  74. data/vendor/snappy/config.log +0 -1640
  75. data/vendor/snappy/config.status +0 -2318
  76. data/vendor/snappy/config.sub +0 -1773
  77. data/vendor/snappy/configure +0 -18852
  78. data/vendor/snappy/configure.ac +0 -134
  79. data/vendor/snappy/depcomp +0 -688
  80. data/vendor/snappy/install-sh +0 -527
  81. data/vendor/snappy/libtool +0 -10246
  82. data/vendor/snappy/ltmain.sh +0 -9661
  83. data/vendor/snappy/m4/gtest.m4 +0 -74
  84. data/vendor/snappy/m4/libtool.m4 +0 -8001
  85. data/vendor/snappy/m4/ltoptions.m4 +0 -384
  86. data/vendor/snappy/m4/ltsugar.m4 +0 -123
  87. data/vendor/snappy/m4/ltversion.m4 +0 -23
  88. data/vendor/snappy/m4/lt~obsolete.m4 +0 -98
  89. data/vendor/snappy/missing +0 -331
  90. data/vendor/snappy/snappy-stubs-public.h +0 -100
  91. data/vendor/snappy/snappy.pc +0 -10
  92. data/vendor/snappy/snappy.pc.in +0 -10
  93. data/vendor/snappy/stamp-h1 +0 -1
@@ -31,249 +31,110 @@
31
31
  #ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
32
32
  #define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_
33
33
 
34
- #include <iostream>
35
- #include <string>
34
+ #if HAVE_CONFIG_H
35
+ #include "config.h"
36
+ #endif
36
37
 
37
38
  #include "snappy-stubs-internal.h"
38
39
 
39
- #include <stdio.h>
40
- #include <stdarg.h>
41
-
42
- #ifdef HAVE_SYS_MMAN_H
40
+ #if HAVE_SYS_MMAN_H
43
41
  #include <sys/mman.h>
44
42
  #endif
45
43
 
46
- #ifdef HAVE_SYS_RESOURCE_H
44
+ #if HAVE_SYS_RESOURCE_H
47
45
  #include <sys/resource.h>
48
46
  #endif
49
47
 
50
- #ifdef HAVE_SYS_TIME_H
48
+ #if HAVE_SYS_TIME_H
51
49
  #include <sys/time.h>
52
50
  #endif
53
51
 
54
- #ifdef HAVE_WINDOWS_H
52
+ #if HAVE_WINDOWS_H
53
+ // Needed to be able to use std::max without workarounds in the source code.
54
+ // https://support.microsoft.com/en-us/help/143208/prb-using-stl-in-windows-program-can-cause-min-max-conflicts
55
+ #define NOMINMAX
55
56
  #include <windows.h>
56
57
  #endif
57
58
 
58
- #include <string>
59
-
60
- #ifdef HAVE_GTEST
61
-
62
- #include <gtest/gtest.h>
63
- #undef TYPED_TEST
64
- #define TYPED_TEST TEST
65
- #define INIT_GTEST(argc, argv) ::testing::InitGoogleTest(argc, *argv)
66
-
67
- #else
68
-
69
- // Stubs for if the user doesn't have Google Test installed.
70
-
71
- #define TEST(test_case, test_subcase) \
72
- void Test_ ## test_case ## _ ## test_subcase()
73
- #define INIT_GTEST(argc, argv)
74
-
75
- #define TYPED_TEST TEST
76
- #define EXPECT_EQ CHECK_EQ
77
- #define EXPECT_NE CHECK_NE
78
- #define EXPECT_FALSE(cond) CHECK(!(cond))
79
-
80
- #endif
81
-
82
- #ifdef HAVE_GFLAGS
83
-
84
- #include <gflags/gflags.h>
85
-
86
- // This is tricky; both gflags and Google Test want to look at the command line
87
- // arguments. Google Test seems to be the most happy with unknown arguments,
88
- // though, so we call it first and hope for the best.
89
- #define InitGoogle(argv0, argc, argv, remove_flags) \
90
- INIT_GTEST(argc, argv); \
91
- google::ParseCommandLineFlags(argc, argv, remove_flags);
92
-
93
- #else
94
-
95
- // If we don't have the gflags package installed, these can only be
96
- // changed at compile time.
97
- #define DEFINE_int32(flag_name, default_value, description) \
98
- static int FLAGS_ ## flag_name = default_value;
59
+ #define InitGoogle(argv0, argc, argv, remove_flags) ((void)(0))
99
60
 
100
- #define InitGoogle(argv0, argc, argv, remove_flags) \
101
- INIT_GTEST(argc, argv)
102
-
103
- #endif
104
-
105
- #ifdef HAVE_LIBZ
61
+ #if HAVE_LIBZ
106
62
  #include "zlib.h"
107
63
  #endif
108
64
 
109
- #ifdef HAVE_LIBLZO2
65
+ #if HAVE_LIBLZO2
110
66
  #include "lzo/lzo1x.h"
111
67
  #endif
112
68
 
113
- #ifdef HAVE_LIBLZF
114
- extern "C" {
115
- #include "lzf.h"
116
- }
117
- #endif
118
-
119
- #ifdef HAVE_LIBFASTLZ
120
- #include "fastlz.h"
69
+ #if HAVE_LIBLZ4
70
+ #include "lz4.h"
121
71
  #endif
122
72
 
123
- #ifdef HAVE_LIBQUICKLZ
124
- #include "quicklz.h"
125
- #endif
73
+ namespace file {
126
74
 
127
- namespace {
75
+ // Stubs the class file::Options.
76
+ //
77
+ // This class should not be instantiated explicitly. It should only be used by
78
+ // passing file::Defaults() to file::GetContents() / file::SetContents().
79
+ class OptionsStub {
80
+ public:
81
+ OptionsStub();
82
+ OptionsStub(const OptionsStub &) = delete;
83
+ OptionsStub &operator=(const OptionsStub &) = delete;
84
+ ~OptionsStub();
85
+ };
128
86
 
129
- namespace File {
130
- void Init() { }
131
- } // namespace File
87
+ const OptionsStub &Defaults();
132
88
 
133
- namespace file {
134
- int Defaults() { return 0; }
135
-
136
- class DummyStatus {
137
- public:
138
- void CheckSuccess() { }
139
- };
140
-
141
- DummyStatus GetContents(const string& filename, string* data, int unused) {
142
- FILE* fp = fopen(filename.c_str(), "rb");
143
- if (fp == NULL) {
144
- perror(filename.c_str());
145
- exit(1);
146
- }
147
-
148
- data->clear();
149
- while (!feof(fp)) {
150
- char buf[4096];
151
- size_t ret = fread(buf, 1, 4096, fp);
152
- if (ret == 0 && ferror(fp)) {
153
- perror("fread");
154
- exit(1);
155
- }
156
- data->append(string(buf, ret));
157
- }
158
-
159
- fclose(fp);
160
-
161
- return DummyStatus();
162
- }
89
+ // Stubs the class absl::Status.
90
+ //
91
+ // This class should not be instantiated explicitly. It should only be used by
92
+ // passing the result of file::GetContents() / file::SetContents() to
93
+ // CHECK_OK().
94
+ class StatusStub {
95
+ public:
96
+ StatusStub();
97
+ StatusStub(const StatusStub &);
98
+ StatusStub &operator=(const StatusStub &);
99
+ ~StatusStub();
163
100
 
164
- DummyStatus SetContents(const string& filename,
165
- const string& str,
166
- int unused) {
167
- FILE* fp = fopen(filename.c_str(), "wb");
168
- if (fp == NULL) {
169
- perror(filename.c_str());
170
- exit(1);
171
- }
101
+ bool ok();
102
+ };
172
103
 
173
- int ret = fwrite(str.data(), str.size(), 1, fp);
174
- if (ret != 1) {
175
- perror("fwrite");
176
- exit(1);
177
- }
104
+ StatusStub GetContents(const std::string &file_name, std::string *output,
105
+ const OptionsStub & /* options */);
178
106
 
179
- fclose(fp);
107
+ StatusStub SetContents(const std::string &file_name, const std::string &content,
108
+ const OptionsStub & /* options */);
180
109
 
181
- return DummyStatus();
182
- }
183
110
  } // namespace file
184
111
 
185
- } // namespace
186
-
187
112
  namespace snappy {
188
113
 
189
114
  #define FLAGS_test_random_seed 301
190
- typedef string TypeParam;
191
-
192
- void Test_CorruptedTest_VerifyCorrupted();
193
- void Test_Snappy_SimpleTests();
194
- void Test_Snappy_MaxBlowup();
195
- void Test_Snappy_RandomData();
196
- void Test_Snappy_FourByteOffset();
197
- void Test_SnappyCorruption_TruncatedVarint();
198
- void Test_SnappyCorruption_UnterminatedVarint();
199
- void Test_SnappyCorruption_OverflowingVarint();
200
- void Test_Snappy_ReadPastEndOfBuffer();
201
- void Test_Snappy_FindMatchLength();
202
- void Test_Snappy_FindMatchLengthRandom();
203
-
204
- string ReadTestDataFile(const string& base, size_t size_limit);
205
115
 
206
- string ReadTestDataFile(const string& base);
116
+ std::string ReadTestDataFile(const std::string& base, size_t size_limit);
207
117
 
208
- // A sprintf() variant that returns a std::string.
118
+ // A std::sprintf() variant that returns a std::string.
209
119
  // Not safe for general use due to truncation issues.
210
- string StringPrintf(const char* format, ...);
211
-
212
- // A simple, non-cryptographically-secure random generator.
213
- class ACMRandom {
214
- public:
215
- explicit ACMRandom(uint32 seed) : seed_(seed) {}
216
-
217
- int32 Next();
218
-
219
- int32 Uniform(int32 n) {
220
- return Next() % n;
221
- }
222
- uint8 Rand8() {
223
- return static_cast<uint8>((Next() >> 1) & 0x000000ff);
224
- }
225
- bool OneIn(int X) { return Uniform(X) == 0; }
226
-
227
- // Skewed: pick "base" uniformly from range [0,max_log] and then
228
- // return "base" random bits. The effect is to pick a number in the
229
- // range [0,2^max_log-1] with bias towards smaller numbers.
230
- int32 Skewed(int max_log);
231
-
232
- private:
233
- static const uint32 M = 2147483647L; // 2^31-1
234
- uint32 seed_;
235
- };
236
-
237
- inline int32 ACMRandom::Next() {
238
- static const uint64 A = 16807; // bits 14, 8, 7, 5, 2, 1, 0
239
- // We are computing
240
- // seed_ = (seed_ * A) % M, where M = 2^31-1
241
- //
242
- // seed_ must not be zero or M, or else all subsequent computed values
243
- // will be zero or M respectively. For all other values, seed_ will end
244
- // up cycling through every number in [1,M-1]
245
- uint64 product = seed_ * A;
246
-
247
- // Compute (product % M) using the fact that ((x << 31) % M) == x.
248
- seed_ = (product >> 31) + (product & M);
249
- // The first reduction may overflow by 1 bit, so we may need to repeat.
250
- // mod == M is not possible; using > allows the faster sign-bit-based test.
251
- if (seed_ > M) {
252
- seed_ -= M;
253
- }
254
- return seed_;
255
- }
256
-
257
- inline int32 ACMRandom::Skewed(int max_log) {
258
- const int32 base = (Next() - 1) % (max_log+1);
259
- return (Next() - 1) & ((1u << base)-1);
260
- }
120
+ std::string StrFormat(const char* format, ...);
261
121
 
262
122
  // A wall-time clock. This stub is not super-accurate, nor resistant to the
263
123
  // system time changing.
264
124
  class CycleTimer {
265
125
  public:
266
- CycleTimer() : real_time_us_(0) {}
126
+ inline CycleTimer() : real_time_us_(0) {}
127
+ inline ~CycleTimer() = default;
267
128
 
268
- void Start() {
129
+ inline void Start() {
269
130
  #ifdef WIN32
270
131
  QueryPerformanceCounter(&start_);
271
132
  #else
272
- gettimeofday(&start_, NULL);
133
+ ::gettimeofday(&start_, nullptr);
273
134
  #endif
274
135
  }
275
136
 
276
- void Stop() {
137
+ inline void Stop() {
277
138
  #ifdef WIN32
278
139
  LARGE_INTEGER stop;
279
140
  LARGE_INTEGER frequency;
@@ -284,65 +145,78 @@ class CycleTimer {
284
145
  frequency.QuadPart;
285
146
  real_time_us_ += elapsed * 1e6 + 0.5;
286
147
  #else
287
- struct timeval stop;
288
- gettimeofday(&stop, NULL);
148
+ struct ::timeval stop;
149
+ ::gettimeofday(&stop, nullptr);
289
150
 
290
151
  real_time_us_ += 1000000 * (stop.tv_sec - start_.tv_sec);
291
152
  real_time_us_ += (stop.tv_usec - start_.tv_usec);
292
153
  #endif
293
154
  }
294
155
 
295
- double Get() {
296
- return real_time_us_ * 1e-6;
297
- }
156
+ inline double Get() { return real_time_us_ * 1e-6; }
298
157
 
299
158
  private:
300
- int64 real_time_us_;
159
+ int64_t real_time_us_;
301
160
  #ifdef WIN32
302
161
  LARGE_INTEGER start_;
303
162
  #else
304
- struct timeval start_;
163
+ struct ::timeval start_;
305
164
  #endif
306
165
  };
307
166
 
308
- // Minimalistic microbenchmark framework.
167
+ // Logging.
168
+
169
+ class LogMessage {
170
+ public:
171
+ inline LogMessage() = default;
172
+ ~LogMessage();
309
173
 
310
- typedef void (*BenchmarkFunction)(int, int);
174
+ LogMessage &operator<<(const std::string &message);
175
+ LogMessage &operator<<(int number);
176
+ };
311
177
 
312
- class Benchmark {
178
+ class LogMessageCrash : public LogMessage {
313
179
  public:
314
- Benchmark(const string& name, BenchmarkFunction function) :
315
- name_(name), function_(function) {}
180
+ inline LogMessageCrash() = default;
181
+ ~LogMessageCrash();
182
+ };
316
183
 
317
- Benchmark* DenseRange(int start, int stop) {
318
- start_ = start;
319
- stop_ = stop;
320
- return this;
321
- }
184
+ // This class is used to explicitly ignore values in the conditional
185
+ // logging macros. This avoids compiler warnings like "value computed
186
+ // is not used" and "statement has no effect".
322
187
 
323
- void Run();
188
+ class LogMessageVoidify {
189
+ public:
190
+ inline LogMessageVoidify() = default;
191
+ inline ~LogMessageVoidify() = default;
324
192
 
325
- private:
326
- const string name_;
327
- const BenchmarkFunction function_;
328
- int start_, stop_;
193
+ // This has to be an operator with a precedence lower than << but
194
+ // higher than ?:
195
+ inline void operator&(const LogMessage &) {}
329
196
  };
330
- #define BENCHMARK(benchmark_name) \
331
- Benchmark* Benchmark_ ## benchmark_name = \
332
- (new Benchmark(#benchmark_name, benchmark_name))
333
197
 
334
- extern Benchmark* Benchmark_BM_UFlat;
335
- extern Benchmark* Benchmark_BM_UIOVec;
336
- extern Benchmark* Benchmark_BM_UValidate;
337
- extern Benchmark* Benchmark_BM_ZFlat;
198
+ // Asserts, both versions activated in debug mode only,
199
+ // and ones that are always active.
338
200
 
339
- void ResetBenchmarkTiming();
340
- void StartBenchmarkTiming();
341
- void StopBenchmarkTiming();
342
- void SetBenchmarkLabel(const string& str);
343
- void SetBenchmarkBytesProcessed(int64 bytes);
201
+ #define CRASH_UNLESS(condition) \
202
+ SNAPPY_PREDICT_TRUE(condition) \
203
+ ? (void)0 \
204
+ : snappy::LogMessageVoidify() & snappy::LogMessageCrash()
344
205
 
345
- #ifdef HAVE_LIBZ
206
+ #define LOG(level) LogMessage()
207
+ #define VLOG(level) \
208
+ true ? (void)0 : snappy::LogMessageVoidify() & snappy::LogMessage()
209
+
210
+ #define CHECK(cond) CRASH_UNLESS(cond)
211
+ #define CHECK_LE(a, b) CRASH_UNLESS((a) <= (b))
212
+ #define CHECK_GE(a, b) CRASH_UNLESS((a) >= (b))
213
+ #define CHECK_EQ(a, b) CRASH_UNLESS((a) == (b))
214
+ #define CHECK_NE(a, b) CRASH_UNLESS((a) != (b))
215
+ #define CHECK_LT(a, b) CRASH_UNLESS((a) < (b))
216
+ #define CHECK_GT(a, b) CRASH_UNLESS((a) > (b))
217
+ #define CHECK_OK(cond) (cond).ok()
218
+
219
+ #if HAVE_LIBZ
346
220
 
347
221
  // Object-oriented wrapper around zlib.
348
222
  class ZLib {
@@ -465,135 +339,4 @@ class ZLib {
465
339
 
466
340
  } // namespace snappy
467
341
 
468
- DECLARE_bool(run_microbenchmarks);
469
-
470
- static void RunSpecifiedBenchmarks() {
471
- if (!FLAGS_run_microbenchmarks) {
472
- return;
473
- }
474
-
475
- fprintf(stderr, "Running microbenchmarks.\n");
476
- #ifndef NDEBUG
477
- fprintf(stderr, "WARNING: Compiled with assertions enabled, will be slow.\n");
478
- #endif
479
- #ifndef __OPTIMIZE__
480
- fprintf(stderr, "WARNING: Compiled without optimization, will be slow.\n");
481
- #endif
482
- fprintf(stderr, "Benchmark Time(ns) CPU(ns) Iterations\n");
483
- fprintf(stderr, "---------------------------------------------------\n");
484
-
485
- snappy::Benchmark_BM_UFlat->Run();
486
- snappy::Benchmark_BM_UIOVec->Run();
487
- snappy::Benchmark_BM_UValidate->Run();
488
- snappy::Benchmark_BM_ZFlat->Run();
489
-
490
- fprintf(stderr, "\n");
491
- }
492
-
493
- #ifndef HAVE_GTEST
494
-
495
- static inline int RUN_ALL_TESTS() {
496
- fprintf(stderr, "Running correctness tests.\n");
497
- snappy::Test_CorruptedTest_VerifyCorrupted();
498
- snappy::Test_Snappy_SimpleTests();
499
- snappy::Test_Snappy_MaxBlowup();
500
- snappy::Test_Snappy_RandomData();
501
- snappy::Test_Snappy_FourByteOffset();
502
- snappy::Test_SnappyCorruption_TruncatedVarint();
503
- snappy::Test_SnappyCorruption_UnterminatedVarint();
504
- snappy::Test_SnappyCorruption_OverflowingVarint();
505
- snappy::Test_Snappy_ReadPastEndOfBuffer();
506
- snappy::Test_Snappy_FindMatchLength();
507
- snappy::Test_Snappy_FindMatchLengthRandom();
508
- fprintf(stderr, "All tests passed.\n");
509
-
510
- return 0;
511
- }
512
-
513
- #endif // HAVE_GTEST
514
-
515
- // For main().
516
- namespace snappy {
517
-
518
- static void CompressFile(const char* fname);
519
- static void UncompressFile(const char* fname);
520
- static void MeasureFile(const char* fname);
521
-
522
- // Logging.
523
-
524
- #define LOG(level) LogMessage()
525
- #define VLOG(level) true ? (void)0 : \
526
- snappy::LogMessageVoidify() & snappy::LogMessage()
527
-
528
- class LogMessage {
529
- public:
530
- LogMessage() { }
531
- ~LogMessage() {
532
- cerr << endl;
533
- }
534
-
535
- LogMessage& operator<<(const std::string& msg) {
536
- cerr << msg;
537
- return *this;
538
- }
539
- LogMessage& operator<<(int x) {
540
- cerr << x;
541
- return *this;
542
- }
543
- };
544
-
545
- // Asserts, both versions activated in debug mode only,
546
- // and ones that are always active.
547
-
548
- #define CRASH_UNLESS(condition) \
549
- PREDICT_TRUE(condition) ? (void)0 : \
550
- snappy::LogMessageVoidify() & snappy::LogMessageCrash()
551
-
552
- #ifdef _MSC_VER
553
- // ~LogMessageCrash calls abort() and therefore never exits. This is by design
554
- // so temporarily disable warning C4722.
555
- #pragma warning(push)
556
- #pragma warning(disable:4722)
557
- #endif
558
-
559
- class LogMessageCrash : public LogMessage {
560
- public:
561
- LogMessageCrash() { }
562
- ~LogMessageCrash() {
563
- cerr << endl;
564
- abort();
565
- }
566
- };
567
-
568
- #ifdef _MSC_VER
569
- #pragma warning(pop)
570
- #endif
571
-
572
- // This class is used to explicitly ignore values in the conditional
573
- // logging macros. This avoids compiler warnings like "value computed
574
- // is not used" and "statement has no effect".
575
-
576
- class LogMessageVoidify {
577
- public:
578
- LogMessageVoidify() { }
579
- // This has to be an operator with a precedence lower than << but
580
- // higher than ?:
581
- void operator&(const LogMessage&) { }
582
- };
583
-
584
- #define CHECK(cond) CRASH_UNLESS(cond)
585
- #define CHECK_LE(a, b) CRASH_UNLESS((a) <= (b))
586
- #define CHECK_GE(a, b) CRASH_UNLESS((a) >= (b))
587
- #define CHECK_EQ(a, b) CRASH_UNLESS((a) == (b))
588
- #define CHECK_NE(a, b) CRASH_UNLESS((a) != (b))
589
- #define CHECK_LT(a, b) CRASH_UNLESS((a) < (b))
590
- #define CHECK_GT(a, b) CRASH_UNLESS((a) > (b))
591
- #define CHECK_OK(cond) (cond).CheckSuccess()
592
-
593
- } // namespace
594
-
595
- using snappy::CompressFile;
596
- using snappy::UncompressFile;
597
- using snappy::MeasureFile;
598
-
599
342
  #endif // THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_TEST_H_