Add unit tests for most of util.cpp
This commit is contained in:
@@ -19,15 +19,17 @@ enum WorldType {
|
||||
WORLD_TYPE_MASTER,
|
||||
};
|
||||
|
||||
using stringvec = std::vector<std::string>;
|
||||
using stringset = std::set<std::string>;
|
||||
using StringVec = std::vector<std::string>;
|
||||
using HashValue = std::pair<uint64_t, uint64_t>;
|
||||
using IdVector = std::vector<int64_t>;
|
||||
|
||||
// Split a string into multiple strings
|
||||
stringvec split(const std::string &s, char sep);
|
||||
// Unions and sorts two ID vectors.
|
||||
IdVector sort_union_id_vectors(const IdVector &v1, const IdVector &v2);
|
||||
|
||||
// String to lowercase/uppercase
|
||||
// Split a string into multiple strings
|
||||
StringVec split(const std::string &s, char sep);
|
||||
|
||||
// String to lowercase/uppercase. Ascii only, no unicode.
|
||||
std::string tolower(std::string input);
|
||||
std::string toupper(std::string input);
|
||||
|
||||
@@ -45,19 +47,18 @@ std::string ltrim(std::string s);
|
||||
std::string rtrim(std::string s);
|
||||
std::string trim(std::string s);
|
||||
|
||||
// Calculate distance between two points
|
||||
double distance_squared(double x1, double y1, double x2, double y2);
|
||||
|
||||
// Read a file as one big string.
|
||||
std::string get_file_contents(const std::string &path);
|
||||
|
||||
// Read a file as a vector of lines.
|
||||
stringvec get_file_lines(const std::string &path);
|
||||
StringVec get_file_lines(const std::string &path);
|
||||
|
||||
// Get a file's fingerprint - ie, size and modification time.
|
||||
std::string get_file_fingerprint(const std::string &path);
|
||||
|
||||
// Calculate distance between two points
|
||||
double distance_squared(double x1, double y1, double x2, double y2);
|
||||
|
||||
|
||||
// An XYZ coordinate, general purpose.
|
||||
struct XYZ {
|
||||
float x, y, z;
|
||||
|
||||
Reference in New Issue
Block a user