diff options
-rw-r--r-- | raul/Deletable.hpp | 5 | ||||
-rw-r--r-- | raul/DoubleBuffer.hpp | 8 | ||||
-rw-r--r-- | raul/Exception.hpp | 4 | ||||
-rw-r--r-- | raul/Maid.hpp | 19 | ||||
-rw-r--r-- | raul/Noncopyable.hpp | 10 | ||||
-rw-r--r-- | raul/Path.hpp | 4 | ||||
-rw-r--r-- | raul/Process.hpp | 4 | ||||
-rw-r--r-- | raul/RingBuffer.hpp | 23 | ||||
-rw-r--r-- | raul/Semaphore.hpp | 11 | ||||
-rw-r--r-- | raul/Socket.hpp | 54 | ||||
-rw-r--r-- | raul/Symbol.hpp | 8 | ||||
-rw-r--r-- | raul/TimeSlice.hpp | 10 | ||||
-rw-r--r-- | raul/TimeStamp.hpp | 14 | ||||
-rw-r--r-- | test/maid_test.cpp | 8 | ||||
-rw-r--r-- | test/path_test.cpp | 3 | ||||
-rw-r--r-- | test/ringbuffer_test.cpp | 51 | ||||
-rw-r--r-- | test/symbol_test.cpp | 29 | ||||
-rw-r--r-- | test/time_test.cpp | 3 | ||||
-rw-r--r-- | wscript | 30 |
19 files changed, 159 insertions, 139 deletions
diff --git a/raul/Deletable.hpp b/raul/Deletable.hpp index 02b35c5..9b80d54 100644 --- a/raul/Deletable.hpp +++ b/raul/Deletable.hpp @@ -27,8 +27,9 @@ namespace Raul { class Deletable { public: - Deletable() {} - virtual ~Deletable() {} + Deletable() = default; + + virtual ~Deletable() = default; }; } // namespace Raul diff --git a/raul/DoubleBuffer.hpp b/raul/DoubleBuffer.hpp index 3c4d934..73b5565 100644 --- a/raul/DoubleBuffer.hpp +++ b/raul/DoubleBuffer.hpp @@ -35,7 +35,7 @@ namespace Raul { template<typename T> class DoubleBuffer { public: - inline DoubleBuffer(T val) + explicit DoubleBuffer(T val) : _state(State::READ_WRITE) { _vals[0] = std::move(val); @@ -49,9 +49,11 @@ public: case State::READ_WRITE: case State::READ_LOCK: return _vals[0]; - default: - return _vals[1]; + case State::WRITE_READ: + case State::LOCK_READ: + break; } + return _vals[1]; } inline bool set(T new_val) { diff --git a/raul/Exception.hpp b/raul/Exception.hpp index a1c5dfd..da4a0e0 100644 --- a/raul/Exception.hpp +++ b/raul/Exception.hpp @@ -26,10 +26,10 @@ namespace Raul { /** An exception (unexpected error). */ class Exception : public std::exception { public: - const char* what() const noexcept { return _what.c_str(); } + const char* what() const noexcept override { return _what.c_str(); } protected: - explicit Exception(const std::string& what) : _what(what) {} + explicit Exception(std::string what) : _what(std::move(what)) {} private: const std::string _what; diff --git a/raul/Maid.hpp b/raul/Maid.hpp index 26845b6..fa54871 100644 --- a/raul/Maid.hpp +++ b/raul/Maid.hpp @@ -41,11 +41,11 @@ public: /** An object that can be disposed via Maid::dispose(). */ class Disposable : public Deletable { public: - Disposable() : _maid_next(nullptr) {} + Disposable() = default; private: friend class Maid; - Disposable* _maid_next; + Disposable* _maid_next{}; }; /** Disposable wrapper for any type. */ @@ -54,7 +54,7 @@ public: { public: template<typename... Args> - Managed(Args&&... args) + explicit Managed(Args&&... args) : T(std::forward<Args>(args)...) {} }; @@ -63,14 +63,14 @@ public: template<typename T> class Disposer { public: - Disposer(Maid& maid) : _maid(&maid) {} - Disposer() : _maid(nullptr) {} + explicit Disposer(Maid* maid) : _maid(maid) {} + Disposer() : _maid(nullptr) {} void operator()(T* obj) { if (_maid) { _maid->dispose(obj); } } - Maid* _maid; + Maid* _maid{nullptr}; }; /** A managed pointer that automatically disposes of its contents. @@ -86,7 +86,7 @@ public: /** Return false iff there is currently no garbage. */ inline bool empty() const { - return !(bool)_disposed.load(std::memory_order_relaxed); + return !_disposed.load(std::memory_order_relaxed); } /** Enqueue an object for deletion when cleanup() is called next. @@ -127,8 +127,9 @@ public: /** Make a unique_ptr that will dispose its object when dropped. */ template<class T, class... Args> managed_ptr<T> make_managed(Args&&... args) { - T* obj = new T(std::forward<Args>(args)...); - return std::unique_ptr<T, Disposer<T> >(obj, Disposer<T>(*this)); + return std::unique_ptr<T, Disposer<T> >( + new T(std::forward<Args>(args)...), + Disposer<T>(this)); } private: diff --git a/raul/Noncopyable.hpp b/raul/Noncopyable.hpp index 633df6e..876cee8 100644 --- a/raul/Noncopyable.hpp +++ b/raul/Noncopyable.hpp @@ -20,13 +20,13 @@ namespace Raul { class Noncopyable { -protected: - Noncopyable() {} - ~Noncopyable() {} - -private: +public: Noncopyable(const Noncopyable&) = delete; const Noncopyable& operator=(const Noncopyable&) = delete; + +protected: + Noncopyable() = default; + ~Noncopyable() = default; }; } // namespace Raul diff --git a/raul/Path.hpp b/raul/Path.hpp index d5116d2..a613e96 100644 --- a/raul/Path.hpp +++ b/raul/Path.hpp @@ -74,9 +74,7 @@ public: * Note this is faster than constructing a Path from another Path's string * since validation is unnecessary. */ - Path(const Path& path) - : std::basic_string<char>(path) - {} + Path(const Path& path) = default; /** Return true iff `c` is a valid Path character. */ static inline bool is_valid_char(char c) { diff --git a/raul/Process.hpp b/raul/Process.hpp index 5804775..717a900 100644 --- a/raul/Process.hpp +++ b/raul/Process.hpp @@ -47,7 +47,7 @@ public: // (in child) // Close all nonstandard file descriptors - struct rlimit max_fds; + struct rlimit max_fds{}; getrlimit(RLIMIT_NOFILE, &max_fds); for (rlim_t fd = 3; fd < max_fds.rlim_cur; ++fd) { close(static_cast<int>(fd)); @@ -79,7 +79,7 @@ public: } private: - Process() {} + Process() = default; }; } // namespace Raul diff --git a/raul/RingBuffer.hpp b/raul/RingBuffer.hpp index dfe5dd2..a7bbfb7 100644 --- a/raul/RingBuffer.hpp +++ b/raul/RingBuffer.hpp @@ -43,11 +43,12 @@ public: @param size Size in bytes (note this may be rounded up). */ explicit RingBuffer(uint32_t size) - : _size(next_power_of_two(size)) + : _write_head(0) + , _read_head(0) + , _size(next_power_of_two(size)) , _size_mask(_size - 1) - , _buf(static_cast<char*>(malloc(_size))) + , _buf(new char[_size]) { - reset(); assert(read_space() == 0); assert(write_space() == _size - 1); } @@ -55,9 +56,7 @@ public: /** Destroy a RingBuffer. */ - inline ~RingBuffer() { - free(_buf); - } + inline ~RingBuffer() = default; /** Reset (empty) the RingBuffer. @@ -160,11 +159,11 @@ private: static inline uint32_t next_power_of_two(uint32_t size) { // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 size--; - size |= size >> 1; - size |= size >> 2; - size |= size >> 4; - size |= size >> 8; - size |= size >> 16; + size |= size >> 1U; + size |= size >> 2U; + size |= size >> 4U; + size |= size >> 8U; + size |= size >> 16U; size++; return size; } @@ -212,7 +211,7 @@ private: const uint32_t _size; ///< Size (capacity) in bytes const uint32_t _size_mask; ///< Mask for fast modulo - char* const _buf; ///< Contents + const std::unique_ptr<char[]> _buf; ///< Contents }; } // namespace Raul diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp index e0fbf18..1dd6e39 100644 --- a/raul/Semaphore.hpp +++ b/raul/Semaphore.hpp @@ -52,7 +52,9 @@ public: Chances are you want 1 wait() per 1 post(), an initial value of 0. */ - inline Semaphore(unsigned initial) { + explicit Semaphore(unsigned initial) + : _sem() + { if (!init(initial)) { throw std::runtime_error("Failed to create semaphore"); } @@ -203,10 +205,7 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) inline bool Semaphore::init(unsigned initial) { - if (sem_init(&_sem, 0, initial)) { - return false; - } - return true; + return !sem_init(&_sem, 0, initial); } inline void @@ -247,7 +246,7 @@ Semaphore::timed_wait(const std::chrono::duration<Rep, Period>& wait) namespace chr = std::chrono; // Use clock_gettime to ensure sem_timedwait uses the same clock - struct timespec time; + struct timespec time{}; clock_gettime(CLOCK_REALTIME, &time); const auto now(chr::seconds(time.tv_sec) + chr::nanoseconds(time.tv_nsec)); diff --git a/raul/Socket.hpp b/raul/Socket.hpp index d41e0dc..57279e7 100644 --- a/raul/Socket.hpp +++ b/raul/Socket.hpp @@ -47,11 +47,11 @@ public: explicit Socket(Type t); /** Wrap an existing open socket. */ - Socket(Type t, - const std::string& uri, - struct sockaddr* addr, - socklen_t addr_len, - int fd); + Socket(Type t, + std::string uri, + struct sockaddr* addr, + socklen_t addr_len, + int fd); ~Socket(); @@ -109,7 +109,7 @@ private: inline Socket::Socket(Type t) : _uri(t == Type::UNIX ? "unix:" : "tcp:") - , _addr(NULL) + , _addr(nullptr) , _addr_len(0) , _type(t) , _sock(-1) @@ -125,12 +125,12 @@ Socket::Socket(Type t) } inline -Socket::Socket(Type t, - const std::string& uri, - struct sockaddr* addr, - socklen_t addr_len, - int fd) - : _uri(uri) +Socket::Socket(Type t, + std::string uri, + struct sockaddr* addr, + socklen_t addr_len, + int fd) + : _uri(std::move(uri)) , _addr(addr) , _addr_len(addr_len) , _type(t) @@ -150,8 +150,8 @@ Socket::set_addr(const std::string& uri) { free(_addr); if (_type == Type::UNIX && uri.substr(0, strlen("unix://")) == "unix://") { - const std::string path = uri.substr(strlen("unix://")); - struct sockaddr_un* uaddr = static_cast<struct sockaddr_un*>( + const std::string path = uri.substr(strlen("unix://")); + auto* uaddr = static_cast<struct sockaddr_un*>( calloc(1, sizeof(struct sockaddr_un))); uaddr->sun_family = AF_UNIX; strncpy(uaddr->sun_path, path.c_str(), sizeof(uaddr->sun_path) - 1); @@ -167,14 +167,14 @@ Socket::set_addr(const std::string& uri) } std::string host = authority.substr(0, port_sep); - const std::string port = authority.substr(port_sep + 1).c_str(); + const std::string port = authority.substr(port_sep + 1); if (host.empty() || host == "*") { host = "0.0.0.0"; // INADDR_ANY } struct addrinfo* ainfo; int st = 0; - if ((st = getaddrinfo(host.c_str(), port.c_str(), NULL, &ainfo))) { + if ((st = getaddrinfo(host.c_str(), port.c_str(), nullptr, &ainfo))) { return false; } @@ -191,21 +191,13 @@ Socket::set_addr(const std::string& uri) inline bool Socket::bind(const std::string& uri) { - if (set_addr(uri) && ::bind(_sock, _addr, _addr_len) != -1) { - return true; - } - - return false; + return set_addr(uri) && ::bind(_sock, _addr, _addr_len) != -1; } inline bool Socket::connect(const std::string& uri) { - if (set_addr(uri) && ::connect(_sock, _addr, _addr_len) != -1) { - return true; - } - - return false; + return set_addr(uri) && ::connect(_sock, _addr, _addr_len) != -1; } inline bool @@ -221,9 +213,9 @@ Socket::listen() inline std::shared_ptr<Socket> Socket::accept() { - socklen_t client_addr_len = _addr_len; - struct sockaddr* client_addr = static_cast<struct sockaddr*>( - calloc(1, client_addr_len)); + socklen_t client_addr_len = _addr_len; + auto* const client_addr = + static_cast<struct sockaddr*>(calloc(1, client_addr_len)); const int conn = ::accept(_sock, client_addr, &client_addr_len); if (conn == -1) { @@ -242,8 +234,8 @@ Socket::accept() } } - return std::shared_ptr<Socket>( - new Socket(_type, client_uri, client_addr, client_addr_len, conn)); + return std::make_shared<Socket>( + _type, client_uri, client_addr, client_addr_len, conn); } inline void diff --git a/raul/Symbol.hpp b/raul/Symbol.hpp index 1189b7b..70062be 100644 --- a/raul/Symbol.hpp +++ b/raul/Symbol.hpp @@ -73,9 +73,7 @@ public: * Note this is faster than constructing a Symbol from another Symbol's * string since validation is unnecessary. */ - Symbol(const Symbol& symbol) - : std::basic_string<char>(symbol) - {} + Symbol(const Symbol& symbol) = default; /** Return true iff `c` is a valid Symbol start character. */ static inline bool is_valid_start_char(char c) { @@ -93,8 +91,8 @@ public: return false; // Must start with a letter or underscore } - for (size_t i = 0; i < str.length(); ++i) { - if (!is_valid_char(str[i])) { + for (auto c : str) { + if (!is_valid_char(c)) { return false; // All characters must be _, a-z, A-Z, 0-9 } } diff --git a/raul/TimeSlice.hpp b/raul/TimeSlice.hpp index c72ca03..3f629ea 100644 --- a/raul/TimeSlice.hpp +++ b/raul/TimeSlice.hpp @@ -95,19 +95,19 @@ public: } inline TimeStamp beats_to_seconds(TimeStamp beats) const { - return TimeStamp(real_unit(), beats.to_double() * 1/(double)_beat_rate); + return TimeStamp(real_unit(), beats.to_double() * 1/_beat_rate); } inline TimeStamp beats_to_ticks(TimeStamp beats) const { - return TimeStamp(ticks_unit(), beats.to_double() * (double)_beat_rate * _tick_rate); + return TimeStamp(ticks_unit(), beats.to_double() * _beat_rate * _tick_rate); } inline TimeStamp ticks_to_seconds(TimeStamp ticks) const { - return TimeStamp(real_unit(), ticks.ticks() * 1/(double)_tick_rate); + return {real_unit(), ticks.ticks() * 1/_tick_rate}; } inline TimeStamp ticks_to_beats(TimeStamp ticks) const { - return TimeStamp(beats_unit(), ticks.ticks() * 1/(double)_tick_rate * _beat_rate); + return {beats_unit(), ticks.ticks() * 1/_tick_rate * _beat_rate}; } /** Start of current sub-cycle in ticks */ @@ -130,7 +130,7 @@ public: inline TimeUnit beats_unit() const { return _start_beats.unit(); } inline TimeUnit ticks_unit() const { return _start_ticks.unit(); } - inline TimeUnit real_unit() const { return TimeUnit(TimeUnit::SECONDS, 0); } + inline TimeUnit real_unit() const { return {TimeUnit::SECONDS, 0}; } private: inline void update_beat_time() { diff --git a/raul/TimeStamp.hpp b/raul/TimeStamp.hpp index 0c671b2..eabddec 100644 --- a/raul/TimeStamp.hpp +++ b/raul/TimeStamp.hpp @@ -45,9 +45,9 @@ public: _ppt = ppt; } - static inline TimeUnit frames(uint32_t srate) { return TimeUnit(FRAMES, srate); } - static inline TimeUnit beats(uint32_t ppqn) { return TimeUnit(BEATS, ppqn); } - static inline TimeUnit seconds() { return TimeUnit(BEATS, std::numeric_limits<uint32_t>::max()); } + static inline TimeUnit frames(uint32_t srate) { return {FRAMES, srate}; } + static inline TimeUnit beats(uint32_t ppqn) { return {BEATS, ppqn}; } + static inline TimeUnit seconds() { return {BEATS, std::numeric_limits<uint32_t>::max()}; } inline Type type() const { return _type; } inline uint32_t ppt() const { return _ppt; } @@ -76,7 +76,7 @@ private: */ class TimeStamp { public: - inline TimeStamp(TimeUnit unit, uint32_t ticks = 0, uint32_t subticks = 0) + explicit TimeStamp(TimeUnit unit, uint32_t ticks = 0, uint32_t subticks = 0) : _ticks(ticks) , _subticks(subticks) , _unit(unit) @@ -209,21 +209,21 @@ operator<<(std::ostream& os, const TimeStamp& t) class FrameStamp : public TimeStamp { public: - inline FrameStamp(uint32_t rate, uint32_t ticks = 0, uint32_t subticks = 0) + explicit FrameStamp(uint32_t rate, uint32_t ticks = 0, uint32_t subticks = 0) : TimeStamp(TimeUnit(TimeUnit::FRAMES, rate), ticks, subticks) {} }; class BeatStamp : public TimeStamp { public: - inline BeatStamp(uint32_t ppqn, uint32_t ticks = 0, uint32_t subticks = 0) + explicit BeatStamp(uint32_t ppqn, uint32_t ticks = 0, uint32_t subticks = 0) : TimeStamp(TimeUnit(TimeUnit::BEATS, ppqn), ticks, subticks) {} }; /** Same thing as TimeStamp really, but makes code clearer and enforces * correct semantics via type safety */ -typedef TimeStamp TimeDuration; +using TimeDuration = TimeStamp; } // namespace Raul diff --git a/test/maid_test.cpp b/test/maid_test.cpp index ba4086a..94e09c6 100644 --- a/test/maid_test.cpp +++ b/test/maid_test.cpp @@ -28,8 +28,8 @@ using Raul::Maid; -static const size_t n_threads = 8; -static const size_t n_junk_per_thread = 1 << 18; +static const size_t n_threads = 8U; +static const size_t n_junk_per_thread = 1U << 18U; static std::atomic<size_t> n_junk(0); static std::atomic<size_t> n_finished_threads(0); @@ -37,7 +37,7 @@ static std::atomic<size_t> n_finished_threads(0); class Junk : public Maid::Disposable { public: explicit Junk(size_t v) : val(v) { ++n_junk; } - ~Junk() { --n_junk; } + ~Junk() override { --n_junk; } size_t val; }; @@ -79,7 +79,7 @@ test() // Create some threads to produce garbage std::vector<std::thread> litterers; for (size_t i = 0; i < n_threads; ++i) { - litterers.push_back(std::thread(litter, &maid)); + litterers.emplace_back(litter, &maid); } // Wait for some garbage to show up if necessary (unlikely) diff --git a/test/path_test.cpp b/test/path_test.cpp index 9391063..538a262 100644 --- a/test/path_test.cpp +++ b/test/path_test.cpp @@ -78,8 +78,7 @@ main() CHECK(!strcmp(Path("/").symbol(), "")); Path original(std::string("/foo/bar")); - Path copy(original); - CHECK(original == copy); + CHECK(original == Path(original)); bool valid = true; try { diff --git a/test/ringbuffer_test.cpp b/test/ringbuffer_test.cpp index aeebacd..daae419 100644 --- a/test/ringbuffer_test.cpp +++ b/test/ringbuffer_test.cpp @@ -28,9 +28,13 @@ namespace { -Raul::RingBuffer* ring = 0; -size_t n_writes = 0; -bool ring_error = false; +using RingBuffer = Raul::RingBuffer; + +struct Context { + std::unique_ptr<RingBuffer> ring; + size_t n_writes{0}; + size_t ring_errors{0}; +}; int gen_msg(int* msg, int start) @@ -56,7 +60,7 @@ cmp_msg(int* msg1, int* msg2) } void -reader() +reader(Context& ctx) { printf("Reader starting\n"); @@ -64,17 +68,17 @@ reader() int read_msg[MSG_SIZE]; // Read from ring size_t count = 0; int start = gen_msg(ref_msg, 0); - for (size_t i = 0; i < n_writes; ++i) { - if (ring->read_space() >= MSG_SIZE * sizeof(int)) { - const uint32_t n_read = ring->read(MSG_SIZE * sizeof(int), read_msg); + for (size_t i = 0; i < ctx.n_writes; ++i) { + if (ctx.ring->read_space() >= MSG_SIZE * sizeof(int)) { + const uint32_t n_read = ctx.ring->read(MSG_SIZE * sizeof(int), read_msg); if (n_read != MSG_SIZE * sizeof(int)) { fprintf(stderr, "FAIL: Read size incorrect\n"); - ring_error = true; + ++ctx.ring_errors; return; } if (!cmp_msg(ref_msg, read_msg)) { fprintf(stderr, "FAIL: Message %zu is corrupt\n", count); - ring_error = true; + ++ctx.ring_errors; return; } start = gen_msg(ref_msg, start); @@ -86,18 +90,18 @@ reader() } void -writer() +writer(Context& ctx) { printf("Writer starting\n"); int write_msg[MSG_SIZE]; // Written to ring int start = gen_msg(write_msg, 0); - for (size_t i = 0; i < n_writes; ++i) { - if (ring->write_space() >= MSG_SIZE * sizeof(int)) { - const uint32_t n_write = ring->write(MSG_SIZE * sizeof(int), write_msg); + for (size_t i = 0; i < ctx.n_writes; ++i) { + if (ctx.ring->write_space() >= MSG_SIZE * sizeof(int)) { + const uint32_t n_write = ctx.ring->write(MSG_SIZE * sizeof(int), write_msg); if (n_write != MSG_SIZE * sizeof(int)) { fprintf(stderr, "FAIL: Write size incorrect\n"); - ring_error = true; + ++ctx.ring_errors; return; } start = gen_msg(write_msg, start); @@ -117,20 +121,24 @@ main(int argc, char** argv) return 1; } + Context ctx; + size_t size = 1024; if (argc > 1) { size = std::stoul(argv[1]); } - n_writes = size * 1024; + ctx.n_writes = size * 1024; if (argc > 2) { - n_writes = std::stoul(argv[2]); + ctx.n_writes = std::stoul(argv[2]); } printf("Testing %zu writes of %u ints to a %zu int ring...\n", - n_writes, MSG_SIZE, size); + ctx.n_writes, MSG_SIZE, size); + + ctx.ring = std::unique_ptr<RingBuffer>(new RingBuffer(uint32_t(size))); - ring = new Raul::RingBuffer(uint32_t(size)); + auto& ring = ctx.ring; if (ring->capacity() < size - 1) { fprintf(stderr, "Ring capacity is smaller than expected\n"); return 1; @@ -187,17 +195,16 @@ main(int argc, char** argv) ring->reset(); - std::thread reader_thread(reader); - std::thread writer_thread(writer); + std::thread reader_thread(reader, std::ref(ctx)); + std::thread writer_thread(writer, std::ref(ctx)); reader_thread.join(); writer_thread.join(); - if (ring_error) { + if (ctx.ring_errors) { fprintf(stderr, "FAIL: Error occurred\n"); return 1; } - delete ring; return 0; } diff --git a/test/symbol_test.cpp b/test/symbol_test.cpp index 0fa0039..4af598b 100644 --- a/test/symbol_test.cpp +++ b/test/symbol_test.cpp @@ -32,27 +32,26 @@ main() } } while (0) std::list<std::string> names; - names.push_back("Dry/Wet Balance"); - names.push_back("foo+1bar(baz)"); - names.push_back("ThisCRAR"); - names.push_back("NAME"); - names.push_back("thing with a bunch of spaces"); - names.push_back("thing-with-a-bunch-of-dashes"); - names.push_back("CamelCaseABC"); - names.push_back("Signal Level [dB]"); - names.push_back("Gain dB"); - names.push_back("Dry/Wet Balance"); - names.push_back("Phaser1 - Similar to CSound's phaser1 by Sean Costello"); - names.push_back("1"); - names.push_back(""); + names.emplace_back("Dry/Wet Balance"); + names.emplace_back("foo+1bar(baz)"); + names.emplace_back("ThisCRAR"); + names.emplace_back("NAME"); + names.emplace_back("thing with a bunch of spaces"); + names.emplace_back("thing-with-a-bunch-of-dashes"); + names.emplace_back("CamelCaseABC"); + names.emplace_back("Signal Level [dB]"); + names.emplace_back("Gain dB"); + names.emplace_back("Dry/Wet Balance"); + names.emplace_back("Phaser1 - Similar to CSound's phaser1 by Sean Costello"); + names.emplace_back("1"); + names.emplace_back(""); for (const auto& name : names) { CHECK(!Symbol::symbolify(name).empty()); } Symbol original("sym"); - Symbol copy(original); - CHECK(original == copy); + CHECK(original == Symbol(original)); bool valid = true; try { diff --git a/test/time_test.cpp b/test/time_test.cpp index 61b9b9a..4b72feb 100644 --- a/test/time_test.cpp +++ b/test/time_test.cpp @@ -20,9 +20,6 @@ #include <cstdint> #include <iostream> -using namespace std; -using namespace Raul; - int main() { @@ -127,7 +127,35 @@ def test(ctx): autowaf.post_test(ctx, APPNAME, dirs=['.', 'src', 'test']) def lint(ctx): - subprocess.call('cpplint.py --filter=-whitespace/comments,-whitespace/tab,-whitespace/braces,-whitespace/labels,-build/header_guard,-readability/casting,-whitespace/line_length,-runtime/references,-readability/streams,-build/include_order raul/*', shell=True) + "checks code for style issues" + import subprocess + cmd = ("clang-tidy -p=. -header-filter=.* -checks=\"*," + + "-android*," + + "-clang-analyzer-alpha.*," + + "-cppcoreguidelines-no-malloc," + + "-cppcoreguidelines-owning-memory," + + "-cppcoreguidelines-pro-bounds-array-to-pointer-decay," + + "-cppcoreguidelines-pro-bounds-pointer-arithmetic," + + "-cppcoreguidelines-pro-type-const-cast," + + "-cppcoreguidelines-pro-type-reinterpret-cast," + + "-cppcoreguidelines-pro-type-vararg," + + "-cppcoreguidelines-special-member-functions," + + "-fuchsia-default-arguments," + + "-fuchsia-overloaded-operator," + + "-google-runtime-references," + + "-hicpp-no-array-decay," + + "-hicpp-no-malloc," + + "-hicpp-signed-bitwise," + + "-hicpp-special-member-functions," + + "-hicpp-vararg," + + "-llvm-header-guard," + + "-misc-suspicious-string-compare," + + "-misc-unused-parameters," + + "-modernize-make-unique," + + "-readability-else-after-return," + + "-readability-implicit-bool-conversion\" " + + "../raul/*.hpp ../test/*.cpp") + subprocess.call(cmd, cwd='build', shell=True) def posts(ctx): path = str(ctx.path.abspath()) |