diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-19 00:26:06 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-23 07:05:50 -0500 |
commit | 018e2571aad8c68c80207f84b6b20695f20e5c40 (patch) | |
tree | 786df005464ec975d2781c0f47822700487684e8 /src/libutil | |
parent | 685395332d75713bc7aca0c6408fc1b9d2c14bc5 (diff) |
Test store paths, with property tests
The property test in fact found a bug: we were excluding numbers!
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/regex-combinators.hh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libutil/regex-combinators.hh b/src/libutil/regex-combinators.hh new file mode 100644 index 000000000..0b997b25a --- /dev/null +++ b/src/libutil/regex-combinators.hh @@ -0,0 +1,30 @@ +#pragma once + +#include <string_view> + +namespace nix::regex { + +// TODO use constexpr string building like +// https://github.com/akrzemi1/static_string/blob/master/include/ak_toolkit/static_string.hpp + +static inline std::string either(std::string_view a, std::string_view b) +{ + return std::string { a } + "|" + b; +} + +static inline std::string group(std::string_view a) +{ + return std::string { "(" } + a + ")"; +} + +static inline std::string many(std::string_view a) +{ + return std::string { "(?:" } + a + ")*"; +} + +static inline std::string list(std::string_view a) +{ + return std::string { a } + many(group("," + a)); +} + +} |