tree-sitter/test/helpers/random_helpers.h
Max Brunsfeld 2169c45da9 Store subtree's lookahead byte count relative to its end offset
This improves test coverage for incremental parsing by generalizing
the randomized tests in `real_grammars.cc` to make *multiple* edits
before incrementally re-parsing.
2018-11-02 15:23:38 -07:00

26 lines
599 B
C++

#ifndef HELPERS_RANDOM_HELPERS_H_
#define HELPERS_RANDOM_HELPERS_H_
#include <string>
#include <vector>
#include <random>
unsigned get_time_as_seed();
class Generator {
std::default_random_engine engine;
std::uniform_int_distribution<uint32_t> distribution;
public:
Generator(uint32_t seed) : engine{seed} {}
void reseed(unsigned);
unsigned operator()();
unsigned operator()(unsigned max);
std::string words(size_t count);
std::string str(char min, char max);
std::string select(const std::vector<std::string> &);
void sleep_some();
};
#endif // HELPERS_RANDOM_HELPERS_H_