reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit ce381e3f57ffd801e50868bd280d5a736cecb2e3
parent dc51a73eb31985fe8f47d6168fcd90696fd410ac
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sat,  9 Apr 2016 02:41:09 -0400

some refactoring over e3cf77c35d18ac90a3d2d4c4d7a1bba6d11ea1a0

Diffstat:
Msrc/browser.cpp | 4++--
Msrc/filter.hpp | 8++++++++
Mtest/filter.cpp | 18++++++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -324,8 +324,8 @@ void Browser::checkFilter() const string &filter = from_autostring(wideFilter); - if(filter != m_filter.get()) { - m_filter.set(filter); + if(m_filter != filter) { + m_filter = filter; fillList(); } } diff --git a/src/filter.hpp b/src/filter.hpp @@ -23,10 +23,18 @@ class Filter { public: + Filter() {} + Filter(const std::string &input) { set(input); } + const std::string get() const { return m_input; } void set(const std::string &); + bool match(const std::string &) const; + Filter &operator=(const std::string &f) { set(f); return *this; } + bool operator==(const std::string &f) const { return m_input == f; } + bool operator!=(const std::string &f) const { return !(*this == f); } + private: std::string m_input; std::vector<std::string> m_words; diff --git a/test/filter.cpp b/test/filter.cpp @@ -30,6 +30,24 @@ TEST_CASE("get/set filter", M) { REQUIRE(f.match("world")); } +TEST_CASE("filter operators", M) { + SECTION("assignment") { + Filter f; + f = "hello"; + REQUIRE(f.get() == "hello"); + } + + SECTION("equal") { + REQUIRE(Filter("hello") == "hello"); + REQUIRE_FALSE(Filter("hello") == "world"); + } + + SECTION("not equal") { + REQUIRE_FALSE(Filter("hello") != "hello"); + REQUIRE(Filter("hello") != "world"); + } +} + TEST_CASE("word matching", M) { Filter f; f.set("hello world");