| 30 | } |
| 31 | |
| 32 | Slice CompressibleString(Random* rnd, double compressed_fraction, size_t len, |
| 33 | std::string* dst) { |
| 34 | int raw = static_cast<int>(len * compressed_fraction); |
| 35 | if (raw < 1) raw = 1; |
| 36 | std::string raw_data; |
| 37 | RandomString(rnd, raw, &raw_data); |
| 38 | |
| 39 | // Duplicate the random data until we have filled "len" bytes |
| 40 | dst->clear(); |
| 41 | while (dst->size() < len) { |
| 42 | dst->append(raw_data); |
| 43 | } |
| 44 | dst->resize(len); |
| 45 | return Slice(*dst); |
| 46 | } |
| 47 | |
| 48 | } // namespace test |
| 49 | } // namespace leveldb |
no test coverage detected