This improves test coverage of the lexer. Before, a SpyReader's read function would return pointers into a single string that contained the entire text. This could have masked bugs where out-of-bounds characters were being read. Now the chunks returned by the reader are copied into a separate buffer.
23 lines
419 B
C++
23 lines
419 B
C++
#ifndef HELPERS_SPY_READER_H_
|
|
#define HELPERS_SPY_READER_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "tree_sitter/runtime.h"
|
|
|
|
class SpyReader {
|
|
public:
|
|
SpyReader(std::string content, size_t chunk_size);
|
|
~SpyReader();
|
|
|
|
void clear();
|
|
|
|
char *buffer;
|
|
std::string content;
|
|
size_t position;
|
|
size_t chunk_size;
|
|
TSInput input;
|
|
std::vector<std::string> strings_read;
|
|
};
|
|
|
|
#endif // HELPERS_SPY_READER_H_
|