reapack

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

commit e69872a1635ef49afe1f6efaa5842210045ac54c
parent 954446b2fe51c79b5e834d0c76644753f1f01007
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Wed,  3 Feb 2016 02:57:51 -0500

mark remote index as readonly after load and const cleanup

Diffstat:
Msrc/about.cpp | 6+++---
Msrc/about.hpp | 2+-
Msrc/config.hpp | 4++--
Msrc/database.hpp | 12++++++------
Msrc/dialog.hpp | 10+++++-----
Msrc/index.cpp | 12++++++------
Msrc/index.hpp | 18+++++++++---------
Msrc/listview.hpp | 2+-
Msrc/manager.hpp | 2+-
Msrc/menu.hpp | 12++++++------
Msrc/package.cpp | 8++++----
Msrc/package.hpp | 8++++----
Msrc/path.hpp | 6+++---
Msrc/reapack.hpp | 2+-
Msrc/registry.cpp | 16++++++++--------
Msrc/registry.hpp | 6+++---
Msrc/remote.hpp | 3+--
Msrc/report.cpp | 6+++---
Msrc/source.cpp | 8++++----
Msrc/source.hpp | 10++++++----
Msrc/tabbar.hpp | 4++--
Msrc/task.cpp | 7++++---
Msrc/task.hpp | 6+++---
Msrc/transaction.cpp | 12++++++------
Msrc/transaction.hpp | 8++++----
Msrc/version.cpp | 2+-
Msrc/version.hpp | 17++++++++---------
Mtest/index.cpp | 14+++++++-------
Mtest/index_v1.cpp | 40++++++++++++++++++++--------------------
29 files changed, 132 insertions(+), 131 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -131,7 +131,7 @@ void About::populate() m_cats->addRow({AUTO_STR("<All Categories>")}); - for(Category *cat : m_index->categories()) + for(const Category *cat : m_index->categories()) m_cats->addRow({make_autostring(cat->name())}); m_cats->sortByColumn(0); @@ -163,8 +163,8 @@ void About::updatePackages() InhibitControl lock(m_packages); m_packages->clear(); - for(Package *pkg : *pkgList) { - Version *lastVer = pkg->lastVersion(); + for(const Package *pkg : *pkgList) { + const Version *lastVer = pkg->lastVersion(); const auto_string &name = make_autostring(pkg->name()); const auto_string &version = make_autostring(lastVer->name()); const auto_string &author = make_autostring(lastVer->author()); diff --git a/src/about.hpp b/src/about.hpp @@ -42,7 +42,7 @@ private: void populate(); void updatePackages(); void updateInstalledFiles(); - void selectLink(const int control, const std::vector<const Link *> &); + void selectLink(int control, const std::vector<const Link *> &); void openLink(const Link *); const Remote *m_remote; diff --git a/src/config.hpp b/src/config.hpp @@ -38,10 +38,10 @@ private: std::string getString(const char *, const std::string &) const; void setString(const char *, const std::string &, const std::string &) const; size_t getUInt(const char *, const std::string &) const; - void setUInt(const char *, const std::string &, const size_t) const; + void setUInt(const char *, const std::string &, size_t) const; void deleteKey(const char *, const std::string &) const; void cleanupArray(const char *, const std::string &, - const size_t begin, const size_t end) const; + size_t begin, size_t end) const; void migrate(); diff --git a/src/database.hpp b/src/database.hpp @@ -56,15 +56,15 @@ class Statement { public: typedef std::function<bool (void)> ExecCallback; - void bind(const int index, const std::string &text); - void bind(const int index, const int integer); - void bind(const int index, const uint64_t integer); + void bind(int index, const std::string &text); + void bind(int index, int integer); + void bind(int index, uint64_t integer); void exec(); void exec(const ExecCallback &); - int intColumn(const int index) const; - uint64_t uint64Column(const int index) const; - std::string stringColumn(const int index) const; + int intColumn(int index) const; + uint64_t uint64Column(int index) const; + std::string stringColumn(int index) const; private: friend Database; diff --git a/src/dialog.hpp b/src/dialog.hpp @@ -69,22 +69,22 @@ public: void enable(HWND handle) { setEnabled(true, handle); } void disable() { disable(m_handle); } void disable(HWND handle) { setEnabled(false, handle); } - void setEnabled(const bool enable) { setEnabled(enable, m_handle); } - void setEnabled(const bool, HWND); + void setEnabled(bool enable) { setEnabled(enable, m_handle); } + void setEnabled(bool, HWND); void show(HWND); void show() { show(m_handle); } void hide(HWND); void hide() { hide(m_handle); } - void close(const INT_PTR = 0); + void close(INT_PTR = 0); void center(); void setFocus(); protected: - Dialog(const int templateId); + Dialog(int templateId); virtual ~Dialog(); - HWND getControl(const int idc); + HWND getControl(int idc); template<class T, class... Args> T *createControl(int id, Args&&... args) diff --git a/src/index.cpp b/src/index.cpp @@ -50,7 +50,7 @@ auto RemoteIndex::linkTypeFor(const char *rel) -> LinkType return WebsiteLink; } -RemoteIndex *RemoteIndex::load(const string &name) +const RemoteIndex *RemoteIndex::load(const string &name) { TiXmlDocument doc; @@ -94,11 +94,11 @@ RemoteIndex::RemoteIndex(const string &name) RemoteIndex::~RemoteIndex() { - for(Category *cat : m_categories) + for(const Category *cat : m_categories) delete cat; } -void RemoteIndex::addCategory(Category *cat) +void RemoteIndex::addCategory(const Category *cat) { if(cat->index() != this) throw reapack_error("category belongs to another index"); @@ -131,7 +131,7 @@ auto RemoteIndex::links(const LinkType type) const -> LinkList return list; } -Category::Category(const string &name, RemoteIndex *ri) +Category::Category(const string &name, const RemoteIndex *ri) : m_index(ri), m_name(name) { if(m_name.empty()) @@ -140,7 +140,7 @@ Category::Category(const string &name, RemoteIndex *ri) Category::~Category() { - for(Package *pack : m_packages) + for(const Package *pack : m_packages) delete pack; } @@ -149,7 +149,7 @@ string Category::fullName() const return m_index ? m_index->name() + "/" + m_name : m_name; } -void Category::addPackage(Package *pkg) +void Category::addPackage(const Package *pkg) { if(pkg->category() != this) throw reapack_error("package belongs to another category"); diff --git a/src/index.hpp b/src/index.hpp @@ -25,7 +25,7 @@ #include "package.hpp" class Category; -typedef std::vector<Category *> CategoryList; +typedef std::vector<const Category *> CategoryList; class Path; class TiXmlElement; @@ -40,7 +40,7 @@ public: static Path pathFor(const std::string &name); static LinkType linkTypeFor(const char *rel); - static RemoteIndex *load(const std::string &name); + static const RemoteIndex *load(const std::string &name); RemoteIndex(const std::string &name); ~RemoteIndex(); @@ -52,9 +52,9 @@ public: void addLink(const LinkType, const Link &); LinkList links(const LinkType type) const; - void addCategory(Category *cat); + void addCategory(const Category *cat); const CategoryList &categories() const { return m_categories; } - Category *category(const size_t i) const { return m_categories[i]; } + const Category *category(size_t i) const { return m_categories[i]; } const PackageList &packages() const { return m_packages; } @@ -70,19 +70,19 @@ private: class Category { public: - Category(const std::string &name, RemoteIndex * = nullptr); + Category(const std::string &name, const RemoteIndex * = nullptr); ~Category(); - RemoteIndex *index() const { return m_index; } + const RemoteIndex *index() const { return m_index; } const std::string &name() const { return m_name; } std::string fullName() const; - void addPackage(Package *pack); + void addPackage(const Package *pack); const PackageList &packages() const { return m_packages; } - Package *package(const size_t i) const { return m_packages[i]; } + const Package *package(size_t i) const { return m_packages[i]; } private: - RemoteIndex *m_index; + const RemoteIndex *m_index; std::string m_name; PackageList m_packages; diff --git a/src/listview.hpp b/src/listview.hpp @@ -42,7 +42,7 @@ public: const Row &row(int index) const { return m_rows[index]; } void replaceRow(int index, const Row &); void removeRow(int index); - void resizeColumn(int index, const int width); + void resizeColumn(int index, int width); void sort(); void sortByColumn(int index, SortOrder order = AscendingOrder); void clear(); diff --git a/src/manager.hpp b/src/manager.hpp @@ -43,7 +43,7 @@ private: ListView::Row makeRow(const Remote &remote) const; Remote currentRemote() const; - void setRemoteEnabled(const bool); + void setRemoteEnabled(bool); bool isRemoteEnabled(const Remote &remote) const; void uninstall(); void about(); diff --git a/src/menu.hpp b/src/menu.hpp @@ -34,18 +34,18 @@ public: unsigned int size() { return m_size; } bool empty() const { return m_size == 0; } - UINT addAction(const auto_char *label, const int commandId); + unsigned int addAction(const auto_char *label, int commandId); void addSeparator(); Menu addMenu(const auto_char *label); - void show(const int x, const int y, HWND parent) const; + void show(int x, int y, HWND parent) const; void enable(); - void enable(const UINT); + void enable(unsigned int); void disable(); - void disable(const UINT); - void setEnabled(const bool); - void setEnabled(const bool, const UINT); + void disable(unsigned int); + void setEnabled(bool); + void setEnabled(bool, unsigned int); private: void append(MENUITEMINFO &); diff --git a/src/package.cpp b/src/package.cpp @@ -46,11 +46,11 @@ string Package::fullName() const Package::~Package() { - for(Version *ver : m_versions) + for(const Version *ver : m_versions) delete ver; } -void Package::addVersion(Version *ver) +void Package::addVersion(const Version *ver) { if(ver->package() != this) throw reapack_error("version belongs to another package"); @@ -61,7 +61,7 @@ void Package::addVersion(Version *ver) m_versions.insert(ver); } -Version *Package::version(const size_t index) const +const Version *Package::version(const size_t index) const { auto it = m_versions.begin(); @@ -71,7 +71,7 @@ Version *Package::version(const size_t index) const return *it; } -Version *Package::lastVersion() const +const Version *Package::lastVersion() const { if(m_versions.empty()) return nullptr; diff --git a/src/package.hpp b/src/package.hpp @@ -24,7 +24,7 @@ class Category; class Package; -typedef std::vector<Package *> PackageList; +typedef std::vector<const Package *> PackageList; class Package { public: @@ -43,10 +43,10 @@ public: const std::string &name() const { return m_name; } std::string fullName() const; - void addVersion(Version *ver); + void addVersion(const Version *ver); const VersionSet &versions() const { return m_versions; } - Version *version(const size_t i) const; - Version *lastVersion() const; + const Version *version(size_t index) const; + const Version *lastVersion() const; Path targetPath() const; diff --git a/src/path.hpp b/src/path.hpp @@ -51,14 +51,14 @@ public: bool operator<(const Path &) const; Path operator+(const std::string &) const; Path operator+(const Path &) const; - std::string &operator[](const size_t index); - const std::string &operator[](const size_t index) const; + std::string &operator[](size_t); + const std::string &operator[](size_t) const; private: static Path s_root; friend UseRootPath; - const std::string &at(const size_t) const; + const std::string &at(size_t) const; std::list<std::string> m_parts; }; diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -45,7 +45,7 @@ public: int setupAction(const char *name, const ActionCallback &); int setupAction(const char *name, const char *desc, gaccel_register_t *action, const ActionCallback &); - bool execActions(const int id, const int); + bool execActions(int id, int); void synchronizeAll(); void enable(Remote); diff --git a/src/registry.cpp b/src/registry.cpp @@ -120,14 +120,14 @@ void Registry::migrate() m_db.commit(); } -auto Registry::push(Version *ver, vector<Path> *conflicts) -> Entry +auto Registry::push(const Version *ver, vector<Path> *conflicts) -> Entry { m_savepoint->exec(); bool hasConflicts = false; - Package *pkg = ver->package(); - Category *cat = pkg->category(); - RemoteIndex *ri = cat->index(); + const Package *pkg = ver->package(); + const Category *cat = pkg->category(); + const RemoteIndex *ri = cat->index(); m_clearFiles->bind(1, ri->name()); m_clearFiles->bind(2, cat->name()); @@ -189,7 +189,7 @@ auto Registry::push(Version *ver, vector<Path> *conflicts) -> Entry } } -auto Registry::query(Package *pkg) const -> QueryResult +auto Registry::query(const Package *pkg) const -> QueryResult { const Entry &entry = getEntry(pkg); @@ -202,7 +202,7 @@ auto Registry::query(Package *pkg) const -> QueryResult return {status, entry}; } -auto Registry::getEntry(Package *pkg) const -> Entry +auto Registry::getEntry(const Package *pkg) const -> Entry { int id = 0; string remote; @@ -211,8 +211,8 @@ auto Registry::getEntry(Package *pkg) const -> Entry Package::Type type = Package::UnknownType; uint64_t version = 0; - Category *cat = pkg->category(); - RemoteIndex *ri = cat->index(); + const Category *cat = pkg->category(); + const RemoteIndex *ri = cat->index(); m_findEntry->bind(1, ri->name()); m_findEntry->bind(2, cat->name()); diff --git a/src/registry.hpp b/src/registry.hpp @@ -54,12 +54,12 @@ public: Entry entry; }; - QueryResult query(Package *) const; - Entry getEntry(Package *) const; + QueryResult query(const Package *) const; + Entry getEntry(const Package *) const; std::vector<Entry> getEntries(const Remote &) const; std::set<Path> getFiles(const Entry &) const; std::string getMainFile(const Entry &) const; - Entry push(Version *, std::vector<Path> *conflicts = nullptr); + Entry push(const Version *, std::vector<Path> *conflicts = nullptr); void forget(const Entry &); void commit(); diff --git a/src/remote.hpp b/src/remote.hpp @@ -35,8 +35,7 @@ public: static Remote fromString(const std::string &data, ReadCode *code = nullptr); Remote(); - Remote(const std::string &name, const std::string &url, - const bool enabled = true); + Remote(const std::string &name, const std::string &url, bool enabled = true); std::string toString() const; diff --git a/src/report.cpp b/src/report.cpp @@ -83,7 +83,7 @@ void Report::printNewPackages() printHeader("New packages"); for(const Transaction::InstallTicket &entry : m_transaction->newPackages()) { - Version *ver = entry.first; + const Version *ver = entry.first; m_stream << NL << ver->fullName(); } } @@ -93,11 +93,11 @@ void Report::printUpdates() printHeader("Updates"); for(const Transaction::InstallTicket &entry : m_transaction->updates()) { - Package *pkg = entry.first->package(); + const Package *pkg = entry.first->package(); const auto &queryRes = entry.second; const VersionSet &versions = pkg->versions(); - for(Version *ver : versions | boost::adaptors::reversed) { + for(const Version *ver : versions | boost::adaptors::reversed) { if(ver->code() <= queryRes.entry.version) break; diff --git a/src/source.cpp b/src/source.cpp @@ -44,14 +44,14 @@ Source::Platform Source::ConvertPlatform(const char *platform) } Source::Source(const Platform platform, const string &file, - const string &url, Version *ver) + const string &url, const Version *ver) : m_platform(platform), m_file(file), m_url(url), m_version(ver) { if(m_url.empty()) throw reapack_error("empty source url"); } -Package *Source::package() const +const Package *Source::package() const { return m_version ? m_version->package() : nullptr; } @@ -61,7 +61,7 @@ const string &Source::file() const if(!m_file.empty()) return m_file; - Package *pkg = package(); + const Package *pkg = package(); if(pkg) return pkg->name(); @@ -81,7 +81,7 @@ string Source::fullName() const Path Source::targetPath() const { - Package *pkg = package(); + const Package *pkg = package(); if(!pkg) throw reapack_error("no package associated with the source"); diff --git a/src/source.hpp b/src/source.hpp @@ -18,6 +18,7 @@ #ifndef REAPACK_SOURCE_HPP #define REAPACK_SOURCE_HPP +#include <map> #include <string> #include <vector> @@ -25,6 +26,7 @@ class Source; typedef std::vector<Source *> SourceList; +typedef std::multimap<Path, const Source *> SourceMap; class Package; class Version; @@ -49,7 +51,7 @@ public: static Platform ConvertPlatform(const char *); Source(const Platform, const std::string &file, - const std::string &url, Version * = nullptr); + const std::string &url, const Version * = nullptr); Platform platform() const { return m_platform; } @@ -57,8 +59,8 @@ public: const std::string &file() const; const std::string &url() const { return m_url; } - Version *version() const { return m_version; } - Package *package() const; + const Version *version() const { return m_version; } + const Package *package() const; std::string fullName() const; Path targetPath() const; @@ -67,7 +69,7 @@ private: Platform m_platform; std::string m_file; std::string m_url; - Version *m_version; + const Version *m_version; }; #endif diff --git a/src/tabbar.hpp b/src/tabbar.hpp @@ -33,8 +33,8 @@ public: TabBar(const Tabs &tabs, HWND handle); int addTab(const Tab &); int currentIndex() const; - void setCurrentIndex(const int); - void removeTab(const int); + void setCurrentIndex(int); + void removeTab(int); void setFocus(); protected: diff --git a/src/task.cpp b/src/task.cpp @@ -105,7 +105,8 @@ bool Task::RemoveFileRecursive(const Path &file) return true; } -InstallTask::InstallTask(Version *ver, const set<Path> &oldFiles, Transaction *t) +InstallTask::InstallTask(const Version *ver, + const set<Path> &oldFiles, Transaction *t) : Task(t), m_version(ver), m_oldFiles(move(oldFiles)) { } @@ -116,7 +117,7 @@ void InstallTask::doStart() for(auto it = sources.begin(); it != sources.end();) { const Path &path = it->first; - Source *src = it->second; + const Source *src = it->second; Download *dl = new Download(src->fullName(), src->url()); dl->onFinish(bind(&InstallTask::saveSource, this, dl, src)); @@ -128,7 +129,7 @@ void InstallTask::doStart() } } -void InstallTask::saveSource(Download *dl, Source *src) +void InstallTask::saveSource(Download *dl, const Source *src) { if(isCancelled()) return; diff --git a/src/task.hpp b/src/task.hpp @@ -63,7 +63,7 @@ private: class InstallTask : public Task { public: - InstallTask(Version *ver, const std::set<Path> &oldFiles, Transaction *); + InstallTask(const Version *ver, const std::set<Path> &oldFiles, Transaction *); const std::set<Path> &removedFiles() const { return m_oldFiles; } @@ -75,9 +75,9 @@ protected: private: typedef std::pair<Path, Path> PathPair; - void saveSource(Download *, Source *); + void saveSource(Download *, const Source *); - Version *m_version; + const Version *m_version; std::set<Path> m_oldFiles; std::vector<PathPair> m_newFiles; }; diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -48,7 +48,7 @@ Transaction::~Transaction() for(Task *task : m_tasks) delete task; - for(RemoteIndex *ri : m_remoteIndexes) + for(const RemoteIndex *ri : m_remoteIndexes) delete ri; delete m_registry; @@ -75,7 +75,7 @@ void Transaction::upgradeAll(Download *dl) if(!saveFile(dl, RemoteIndex::pathFor(dl->name()))) return; - RemoteIndex *ri; + const RemoteIndex *ri; try { ri = RemoteIndex::load(dl->name()); @@ -87,13 +87,13 @@ void Transaction::upgradeAll(Download *dl) return; } - for(Package *pkg : ri->packages()) + for(const Package *pkg : ri->packages()) upgrade(pkg); } -void Transaction::upgrade(Package *pkg) +void Transaction::upgrade(const Package *pkg) { - Version *ver = pkg->lastVersion(); + const Version *ver = pkg->lastVersion(); auto queryRes = m_registry->query(pkg); if(queryRes.status == Registry::UpToDate) { @@ -135,7 +135,7 @@ void Transaction::install() const InstallTicket ticket = m_installQueue.front(); m_installQueue.pop(); - Version *ver = ticket.first; + const Version *ver = ticket.first; const Registry::QueryResult queryRes = ticket.second; const set<Path> &currentFiles = m_registry->getFiles(queryRes.entry); diff --git a/src/transaction.hpp b/src/transaction.hpp @@ -36,7 +36,7 @@ public: typedef boost::signals2::signal<void ()> Signal; typedef Signal::slot_type Callback; - typedef std::pair<Version *, const Registry::QueryResult> InstallTicket; + typedef std::pair<const Version *, const Registry::QueryResult> InstallTicket; typedef std::vector<InstallTicket> InstallTicketList; struct Error { @@ -52,7 +52,7 @@ public: void onFinish(const Callback &callback) { m_onFinish.connect(callback); } void onDestroy(const Callback &callback) { m_onDestroy.connect(callback); } - void synchronize(const Remote &, const bool userAction = true); + void synchronize(const Remote &, bool userAction = true); void uninstall(const Remote &); void registerAll(const Remote &); void unregisterAll(const Remote &); @@ -77,7 +77,7 @@ private: void finish(); void upgradeAll(Download *); - void upgrade(Package *pkg); + void upgrade(const Package *pkg); bool allFilesExists(const std::set<Path> &) const; void addTask(Task *); @@ -89,7 +89,7 @@ private: Registry *m_registry; std::set<Remote> m_remotes; - std::vector<RemoteIndex *> m_remoteIndexes; + std::vector<const RemoteIndex *> m_remoteIndexes; DownloadQueue m_downloadQueue; std::queue<InstallTicket> m_installQueue; std::vector<Task *> m_tasks; diff --git a/src/version.cpp b/src/version.cpp @@ -109,7 +109,7 @@ void Version::setChangelog(const std::string &changelog) m_changelog = changelog; } -Source *Version::source(const size_t index) const +const Source *Version::source(const size_t index) const { auto it = m_sources.begin(); diff --git a/src/version.hpp b/src/version.hpp @@ -19,7 +19,6 @@ #define REAPACK_VERSION_HPP #include <cstdint> -#include <map> #include <set> #include <string> @@ -36,7 +35,7 @@ public: std::string fullName() const; uint64_t code() const { return m_code; } - Package *package() const { return m_package; } + const Package *package() const { return m_package; } void setAuthor(const std::string &author) { m_author = author; } const std::string &author() const { return m_author; } @@ -45,9 +44,9 @@ public: const std::string &changelog() const { return m_changelog; } void addSource(Source *source); - const std::multimap<Path, Source *> &sources() const { return m_sources; } - Source *source(const size_t) const; - Source *mainSource() const { return m_mainSource; } + const SourceMap &sources() const { return m_sources; } + const Source *source(size_t) const; + const Source *mainSource() const { return m_mainSource; } const std::set<Path> &files() const { return m_files; } @@ -59,12 +58,12 @@ private: std::string m_name; uint64_t m_code; - Package *m_package; - Source *m_mainSource; + const Package *m_package; + const Source *m_mainSource; std::string m_author; std::string m_changelog; - std::multimap<Path, Source *> m_sources; + SourceMap m_sources; std::set<Path> m_files; }; @@ -76,6 +75,6 @@ public: } }; -typedef std::set<Version *, VersionCompare> VersionSet; +typedef std::set<const Version *, VersionCompare> VersionSet; #endif diff --git a/test/index.cpp b/test/index.cpp @@ -6,7 +6,7 @@ #include <string> #define RIPATH "test/indexes/" -#define RIPTR(ptr) unique_ptr<RemoteIndex> riptr(ptr) +#define RIPTR(ptr) unique_ptr<const RemoteIndex> riptr(ptr) using namespace std; @@ -16,7 +16,7 @@ TEST_CASE("file not found", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("404"); + const RemoteIndex *ri = RemoteIndex::load("404"); RIPTR(ri); FAIL(); } @@ -29,7 +29,7 @@ TEST_CASE("broken", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("broken"); + const RemoteIndex *ri = RemoteIndex::load("broken"); RIPTR(ri); FAIL(); } @@ -42,7 +42,7 @@ TEST_CASE("wrong root tag name", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("wrong_root"); + const RemoteIndex *ri = RemoteIndex::load("wrong_root"); RIPTR(ri); FAIL(); } @@ -55,7 +55,7 @@ TEST_CASE("invalid version", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("invalid_version"); + const RemoteIndex *ri = RemoteIndex::load("invalid_version"); RIPTR(ri); FAIL(); } @@ -68,7 +68,7 @@ TEST_CASE("future version", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("future_version"); + const RemoteIndex *ri = RemoteIndex::load("future_version"); RIPTR(ri); FAIL(); } @@ -80,7 +80,7 @@ TEST_CASE("future version", M) { TEST_CASE("unicode index path", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("Новая папка"); + const RemoteIndex *ri = RemoteIndex::load("Новая папка"); RIPTR(ri); REQUIRE(ri->name() == "Новая папка"); diff --git a/test/index_v1.cpp b/test/index_v1.cpp @@ -7,7 +7,7 @@ #include <string> #define RIPATH "test/indexes/v1/" -#define RIPTR(ptr) unique_ptr<RemoteIndex> riptr(ptr) +#define RIPTR(ptr) unique_ptr<const RemoteIndex> riptr(ptr) using namespace std; @@ -17,7 +17,7 @@ TEST_CASE("unnamed category", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("unnamed_category"); + const RemoteIndex *ri = RemoteIndex::load("unnamed_category"); RIPTR(ri); FAIL(); } @@ -29,7 +29,7 @@ TEST_CASE("unnamed category", M) { TEST_CASE("invalid category tag", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("wrong_category_tag"); + const RemoteIndex *ri = RemoteIndex::load("wrong_category_tag"); RIPTR(ri); REQUIRE(ri->categories().empty()); @@ -38,7 +38,7 @@ TEST_CASE("invalid category tag", M) { TEST_CASE("invalid package tag", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("wrong_package_tag"); + const RemoteIndex *ri = RemoteIndex::load("wrong_package_tag"); RIPTR(ri); REQUIRE(ri->categories().empty()); @@ -48,7 +48,7 @@ TEST_CASE("null package name", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("unnamed_package"); + const RemoteIndex *ri = RemoteIndex::load("unnamed_package"); RIPTR(ri); FAIL(); } @@ -61,7 +61,7 @@ TEST_CASE("null package type", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("missing_type"); + const RemoteIndex *ri = RemoteIndex::load("missing_type"); RIPTR(ri); } catch(const reapack_error &) { @@ -72,7 +72,7 @@ TEST_CASE("null package type", M) { TEST_CASE("read version author", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("author"); + const RemoteIndex *ri = RemoteIndex::load("author"); RIPTR(ri); CHECK(ri->packages().size() == 1); @@ -83,7 +83,7 @@ TEST_CASE("read version author", M) { TEST_CASE("invalid version tag", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("wrong_version_tag"); + const RemoteIndex *ri = RemoteIndex::load("wrong_version_tag"); RIPTR(ri); REQUIRE(ri->categories().empty()); @@ -93,7 +93,7 @@ TEST_CASE("null package version", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("missing_version"); + const RemoteIndex *ri = RemoteIndex::load("missing_version"); RIPTR(ri); FAIL(); } @@ -106,7 +106,7 @@ TEST_CASE("null source url", M) { UseRootPath root(RIPATH); try { - RemoteIndex *ri = RemoteIndex::load("missing_source_url"); + const RemoteIndex *ri = RemoteIndex::load("missing_source_url"); RIPTR(ri); FAIL(); } @@ -118,19 +118,19 @@ TEST_CASE("null source url", M) { TEST_CASE("null source file", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("missing_source_file"); + const RemoteIndex *ri = RemoteIndex::load("missing_source_file"); RIPTR(ri); CHECK(ri->packages().size() == 1); - Package *pkg = ri->category(0)->package(0); + const Package *pkg = ri->category(0)->package(0); REQUIRE(pkg->version(0)->source(0)->file() == pkg->name()); } TEST_CASE("default platform", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("missing_platform"); + const RemoteIndex *ri = RemoteIndex::load("missing_platform"); RIPTR(ri); CHECK(ri->packages().size() == 1); @@ -141,7 +141,7 @@ TEST_CASE("default platform", M) { TEST_CASE("version changelog", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("changelog"); + const RemoteIndex *ri = RemoteIndex::load("changelog"); RIPTR(ri); CHECK(ri->packages().size() == 1); @@ -153,26 +153,26 @@ TEST_CASE("version changelog", M) { TEST_CASE("full index", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("valid_index"); + const RemoteIndex *ri = RemoteIndex::load("valid_index"); RIPTR(ri); REQUIRE(ri->categories().size() == 1); - Category *cat = ri->category(0); + const Category *cat = ri->category(0); REQUIRE(cat->name() == "Category Name"); REQUIRE(cat->packages().size() == 1); - Package *pack = cat->package(0); + const Package *pack = cat->package(0); REQUIRE(pack->type() == Package::ScriptType); REQUIRE(pack->name() == "Hello World.lua"); REQUIRE(pack->versions().size() == 1); - Version *ver = pack->version(0); + const Version *ver = pack->version(0); REQUIRE(ver->name() == "1.0"); REQUIRE(ver->sources().size() == 1); REQUIRE(ver->changelog() == "Fixed a division by zero error."); - Source *source = ver->source(0); + const Source *source = ver->source(0); REQUIRE(source->platform() == Source::GenericPlatform); REQUIRE(source->file() == "test.lua"); REQUIRE(source->url() == "https://google.com/"); @@ -181,7 +181,7 @@ TEST_CASE("full index", M) { TEST_CASE("read index metadata", M) { UseRootPath root(RIPATH); - RemoteIndex *ri = RemoteIndex::load("metadata"); + const RemoteIndex *ri = RemoteIndex::load("metadata"); RIPTR(ri); SECTION("description") {