mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Cleanup branches and add more unit tests
This commit is contained in:
parent
2cf92c92ad
commit
1cf52cae1f
4 changed files with 970 additions and 15 deletions
|
|
@ -17,11 +17,10 @@
|
|||
*/
|
||||
|
||||
#include "branch.hpp"
|
||||
#include "ef.hpp"
|
||||
#include "errno.hpp"
|
||||
#include "num.hpp"
|
||||
|
||||
Branch::Branch()
|
||||
: mode(Branch::Mode::RW)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -37,12 +36,6 @@ Branch::Branch(const u64 &default_minfreespace_)
|
|||
{
|
||||
}
|
||||
|
||||
int
|
||||
Branch::from_string(const std::string_view str_)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
std::string
|
||||
Branch::to_string(void) const
|
||||
{
|
||||
|
|
@ -64,7 +57,6 @@ Branch::to_string(void) const
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if(std::holds_alternative<u64>(_minfreespace))
|
||||
{
|
||||
rv += ',';
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "base_types.h"
|
||||
#include "strvec.hpp"
|
||||
#include "tofrom_string.hpp"
|
||||
#include "fs_path.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
|
@ -31,12 +30,11 @@
|
|||
#include <variant>
|
||||
|
||||
|
||||
class Branch final : public ToFromString
|
||||
class Branch final
|
||||
{
|
||||
public:
|
||||
enum class Mode
|
||||
{
|
||||
INVALID,
|
||||
RO,
|
||||
RW,
|
||||
NC
|
||||
|
|
@ -61,8 +59,7 @@ public:
|
|||
bool ro_or_nc(void) const;
|
||||
|
||||
public:
|
||||
int from_string(const std::string_view str) final;
|
||||
std::string to_string(void) const final;
|
||||
std::string to_string(void) const;
|
||||
|
||||
public:
|
||||
u64 minfreespace() const;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,10 @@ namespace l
|
|||
|
||||
offset = s_.find_first_not_of("+<>-=");
|
||||
if(offset == std::string::npos)
|
||||
return;
|
||||
{
|
||||
*instr_ = s_.substr(0, std::min(s_.size(), (size_t)2));
|
||||
return;
|
||||
}
|
||||
|
||||
if(offset > 1)
|
||||
offset = 2;
|
||||
|
|
@ -293,6 +296,9 @@ namespace l
|
|||
int
|
||||
erase_begin(Branches::Impl *branches_)
|
||||
{
|
||||
if(branches_->empty())
|
||||
return -ENOENT;
|
||||
|
||||
branches_->erase(branches_->begin());
|
||||
|
||||
return 0;
|
||||
|
|
@ -302,6 +308,9 @@ namespace l
|
|||
int
|
||||
erase_end(Branches::Impl *branches_)
|
||||
{
|
||||
if(branches_->empty())
|
||||
return -ENOENT;
|
||||
|
||||
branches_->pop_back();
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue