diff options
author | Adam Szmigin <smidge@xsco.net> | 2020-06-21 18:53:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-21 18:53:51 +0100 |
commit | c650b488f5939c924a8559e2f89c1af222a0263e (patch) | |
tree | 455ebca7b72ab7744dfb0ec98079c9683f71c536 | |
parent | 8f4c54e27fa1924c15cd3a9e9d300a979123decb (diff) | |
parent | dcabc42c32ba75e08e5fca3154cfb42a9cb32a02 (diff) |
Merge pull request #8 from xsco/enh/symbol_visibility
Added symbol visibility declarations
-rw-r--r-- | include/djinterop/album_art.hpp | 1 | ||||
-rw-r--r-- | include/djinterop/config.hpp | 49 | ||||
-rw-r--r-- | include/djinterop/crate.hpp | 3 | ||||
-rw-r--r-- | include/djinterop/database.hpp | 5 | ||||
-rw-r--r-- | include/djinterop/enginelibrary.hpp | 18 | ||||
-rw-r--r-- | include/djinterop/exceptions.hpp | 1 | ||||
-rw-r--r-- | include/djinterop/musical_key.hpp | 1 | ||||
-rw-r--r-- | include/djinterop/pad_color.hpp | 1 | ||||
-rw-r--r-- | include/djinterop/performance_data.hpp | 2 | ||||
-rw-r--r-- | include/djinterop/semantic_version.hpp | 1 | ||||
-rw-r--r-- | include/djinterop/track.hpp | 34 | ||||
-rw-r--r-- | include/djinterop/transaction_guard.hpp | 3 | ||||
-rw-r--r-- | include/meson.build | 1 | ||||
-rw-r--r-- | meson.build | 6 | ||||
-rw-r--r-- | src/djinterop/enginelibrary/el_track_impl.cpp | 4 | ||||
-rw-r--r-- | src/djinterop/impl/track_impl.hpp | 2 | ||||
-rw-r--r-- | src/djinterop/track.cpp | 29 | ||||
-rw-r--r-- | src/meson.build | 22 | ||||
-rw-r--r-- | test/enginelibrary/enginelibrary_test.cpp | 58 | ||||
-rw-r--r-- | test/enginelibrary/schema_test.cpp | 178 | ||||
-rw-r--r-- | test/enginelibrary/track_test.cpp | 4 | ||||
-rw-r--r-- | test/meson.build | 28 |
22 files changed, 176 insertions, 275 deletions
diff --git a/include/djinterop/album_art.hpp b/include/djinterop/album_art.hpp index 14f5515..b5f3739 100644 --- a/include/djinterop/album_art.hpp +++ b/include/djinterop/album_art.hpp @@ -26,7 +26,6 @@ #include <string> #include <vector> - namespace djinterop { // Artwork for tracks diff --git a/include/djinterop/config.hpp b/include/djinterop/config.hpp new file mode 100644 index 0000000..97260cc --- /dev/null +++ b/include/djinterop/config.hpp @@ -0,0 +1,49 @@ +/* + This file is part of libdjinterop. + + libdjinterop is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + libdjinterop is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with libdjinterop. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once +#ifndef DJINTEROP_CONFIG_HPP +#define DJINTEROP_CONFIG_HPP + +#if __cplusplus < 201703L +#error This library needs at least a C++17 compliant compiler +#endif + +#if defined _WIN32 || defined __CYGWIN__ +#define DJINTEROP_SYMBOL_IMPORT __declspec(dllimport) +#define DJINTEROP_SYMBOL_EXPORT __declspec(dllexport) +#define DJINTEROP_SYMBOL_LOCAL +#else +#if __GNUC__ >= 4 +#define DJINTEROP_SYMBOL_IMPORT __attribute__((visibility("default"))) +#define DJINTEROP_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define DJINTEROP_SYMBOL_LOCAL __attribute__((visibility("hidden"))) +#else +#define DJINTEROP_SYMBOL_IMPORT +#define DJINTEROP_SYMBOL_EXPORT +#define DJINTEROP_SYMBOL_LOCAL +#endif +#endif + +#ifdef DJINTEROP_SOURCE // Defined if building the library (cf. using it) +#define DJINTEROP_PUBLIC DJINTEROP_SYMBOL_EXPORT +#else +#define DJINTEROP_PUBLIC DJINTEROP_SYMBOL_IMPORT +#endif // DJINTEROP_SOURCE +#define DJINTEROP_LOCAL DJINTEROP_SYMBOL_LOCAL + +#endif // DJINTEROP_CONFIG_HPP diff --git a/include/djinterop/crate.hpp b/include/djinterop/crate.hpp index 4d12b33..8a961ce 100644 --- a/include/djinterop/crate.hpp +++ b/include/djinterop/crate.hpp @@ -27,6 +27,7 @@ Lesser General Public License for more details. #include <string> #include <vector> +#include <djinterop/config.hpp> namespace djinterop { @@ -46,7 +47,7 @@ class track; /// A `crate` object becomes invalid if the crate gets deleted by /// `database::remove_crate()`. After that, you must not call any methods on the /// `crate` object, except for destructing it, or assigning to it. -class crate +class DJINTEROP_PUBLIC crate { public: /// Copy constructor diff --git a/include/djinterop/database.hpp b/include/djinterop/database.hpp index 60a4c73..9f68d61 100644 --- a/include/djinterop/database.hpp +++ b/include/djinterop/database.hpp @@ -30,6 +30,7 @@ #include <string> #include <vector> +#include <djinterop/config.hpp> namespace sqlite { @@ -53,7 +54,7 @@ public: } }; -class database +class DJINTEROP_PUBLIC database { public: /// Copy constructor @@ -103,7 +104,7 @@ public: /// Returns the UUID of the database std::string uuid() const; - /// Verifies the consistence of the internal storage of the database. + /// Verifies the consistency of the internal storage of the database. /// /// A `database_inconsistency` (or some exception derived from it) is thrown /// if any kind of inconsistency is found. diff --git a/include/djinterop/enginelibrary.hpp b/include/djinterop/enginelibrary.hpp index de94267..588d293 100644 --- a/include/djinterop/enginelibrary.hpp +++ b/include/djinterop/enginelibrary.hpp @@ -28,10 +28,10 @@ #include <string> #include <vector> +#include <djinterop/config.hpp> #include <djinterop/pad_color.hpp> #include <djinterop/semantic_version.hpp> - namespace djinterop { class database; @@ -67,7 +67,7 @@ constexpr const char* default_database_dir_name = "Engine Library"; /// By convention, the last part of the directory path is "Engine Library". If /// a database already exists in the target directory, an exception will be /// thrown. -database create_database( +database DJINTEROP_PUBLIC create_database( std::string directory, const semantic_version& schema_version = version_latest); @@ -77,23 +77,23 @@ database create_database( /// it will be created at the specified schema version. In both cases, the /// database is returned. The boolean reference parameter `created` can be used /// to determine whether the database was created or merely loaded. -database create_or_load_database( +database DJINTEROP_PUBLIC create_or_load_database( std::string directory, const semantic_version& schema_version, bool& created); /// Returns a boolean indicating whether an Engine Library already exists in a /// given directory. -bool database_exists(const std::string& directory); +bool DJINTEROP_PUBLIC database_exists(const std::string& directory); /// Loads an Engine Library database from a given directory. -database load_database(std::string directory); +database DJINTEROP_PUBLIC load_database(std::string directory); /// Given an Engine Library database, returns the path to its m.db sqlite /// database file /// /// If the given database is not an enginelibrary, then the behaviour of this /// function is undefined. -std::string music_db_path(const database& db); +std::string DJINTEROP_PUBLIC music_db_path(const database& db); /// Normalizes a beat-grid, so that the beat indexes are in the form normally /// expected by Engine Prime. @@ -103,15 +103,15 @@ std::string music_db_path(const database& db); /// usable end of the track, which may not necessarily be aligned to the first /// beat of a 4-beat bar. Therefore, the sample offsets typically recorded by /// Engine Prime do not lie within the actual track. -std::vector<beatgrid_marker> normalize_beatgrid( - std::vector<beatgrid_marker> beatgrid, int64_t sample_count); +std::vector<beatgrid_marker> DJINTEROP_PUBLIC +normalize_beatgrid(std::vector<beatgrid_marker> beatgrid, int64_t sample_count); /// Given an enginelibrary database, returns the path to its p.db sqlite /// database file /// /// If the given database is not an enginelibrary, then the behaviour of this /// function is undefined. -std::string perfdata_db_path(const database& db); +std::string DJINTEROP_PUBLIC perfdata_db_path(const database& db); } // namespace enginelibrary } // namespace djinterop diff --git a/include/djinterop/exceptions.hpp b/include/djinterop/exceptions.hpp index d27d37c..1df3a78 100644 --- a/include/djinterop/exceptions.hpp +++ b/include/djinterop/exceptions.hpp @@ -29,7 +29,6 @@ #include <djinterop/semantic_version.hpp> - namespace djinterop { /// The `database_inconsistency` exception is thrown when the schema of a diff --git a/include/djinterop/musical_key.hpp b/include/djinterop/musical_key.hpp index b4766c7..c86a4e5 100644 --- a/include/djinterop/musical_key.hpp +++ b/include/djinterop/musical_key.hpp @@ -23,7 +23,6 @@ #error This library needs at least a C++17 compliant compiler #endif - namespace djinterop { /** diff --git a/include/djinterop/pad_color.hpp b/include/djinterop/pad_color.hpp index 7317b57..e85de4b 100644 --- a/include/djinterop/pad_color.hpp +++ b/include/djinterop/pad_color.hpp @@ -25,7 +25,6 @@ #include <cstdint> - namespace djinterop { /** diff --git a/include/djinterop/performance_data.hpp b/include/djinterop/performance_data.hpp index 620e676..1a4116b 100644 --- a/include/djinterop/performance_data.hpp +++ b/include/djinterop/performance_data.hpp @@ -26,9 +26,9 @@ #include <cstdint> #include <string> +#include <djinterop/config.hpp> #include <djinterop/pad_color.hpp> - namespace djinterop { struct sampling_info diff --git a/include/djinterop/semantic_version.hpp b/include/djinterop/semantic_version.hpp index 15a834c..f493850 100644 --- a/include/djinterop/semantic_version.hpp +++ b/include/djinterop/semantic_version.hpp @@ -25,7 +25,6 @@ #include <ostream> - namespace djinterop { struct semantic_version diff --git a/include/djinterop/track.hpp b/include/djinterop/track.hpp index be4bb3b..e058fd0 100644 --- a/include/djinterop/track.hpp +++ b/include/djinterop/track.hpp @@ -32,11 +32,11 @@ #include <string> #include <vector> +#include <djinterop/config.hpp> #include <djinterop/musical_key.hpp> #include <djinterop/performance_data.hpp> #include <djinterop/semantic_version.hpp> - namespace djinterop { class database; @@ -46,30 +46,15 @@ class track_impl; /// The `track_import_info` struct holds information about a track in a /// different, external Engine Library database. This can be associated with a /// track if it was imported into the current database from another one. -class track_import_info +struct track_import_info { -public: - track_import_info() noexcept; - track_import_info( - std::string external_db_uuid, int64_t externl_track_id) noexcept; - - /// Gets the UUID of the external Engine Library database. - std::string& external_db_uuid(); - - /// Gets a reference to a field holding the UUID of the external Engine - /// Library database. - const std::string& external_db_uuid() const; + // TODO (mr-smidge): Refactor to remove Engine-specific details. - /// Gets the id of the track in the external Engine Library database. - int64_t& external_track_id(); + /// The UUID of the external Engine Library database. + std::string external_db_uuid; - /// Gets a reference to a field holding the id of the track in the external - /// Engine Library database. - const int64_t& external_track_id() const; - -private: - std::string external_db_uuid_; - int64_t external_track_id_; + /// The id of the track in the external Engine Library database. + int64_t external_track_id; }; /// A `track` object is a handle to a track stored in a database. As long as it @@ -84,7 +69,7 @@ private: /// A `track` object becomes invalid if the track gets deleted by /// `database::remove_track()`. After that, you must not call any methods on the /// `track` object, except for destructing it, or assigning to it. -class track +class DJINTEROP_PUBLIC track { public: /// Copy constructor @@ -258,8 +243,7 @@ public: std::chrono::system_clock::time_point last_modified_at) const; /// Returns the time at which the track was last played - std::optional<std::chrono::system_clock::time_point> last_played_at() - const; + std::optional<std::chrono::system_clock::time_point> last_played_at() const; /// Sets the time at which the track was last played void set_last_played_at( diff --git a/include/djinterop/transaction_guard.hpp b/include/djinterop/transaction_guard.hpp index 9fe4525..35c84e1 100644 --- a/include/djinterop/transaction_guard.hpp +++ b/include/djinterop/transaction_guard.hpp @@ -25,12 +25,13 @@ #include <memory> +#include <djinterop/config.hpp> namespace djinterop { class transaction_guard_impl; -class transaction_guard +class DJINTEROP_PUBLIC transaction_guard { public: transaction_guard() noexcept; diff --git a/include/meson.build b/include/meson.build index d709d3a..ee89840 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,5 +1,6 @@ djinterop_header_files = [ 'djinterop/album_art.hpp', + 'djinterop/config.hpp', 'djinterop/crate.hpp', 'djinterop/database.hpp', 'djinterop/djinterop.hpp', diff --git a/meson.build b/meson.build index 3a4b456..c38bab5 100644 --- a/meson.build +++ b/meson.build @@ -5,10 +5,14 @@ project( license: 'LGPL-3.0', default_options: ['cpp_std=c++17', 'default_library=both']) +cpp_compiler = meson.get_compiler('cpp') add_global_arguments('-D_MODERN_SQLITE_BOOST_OPTIONAL_SUPPORT', language: 'cpp') +if cpp_compiler.get_id() == 'msvc' + # Ask MSVC to populate the __cplusplus macro properly. + add_global_arguments('/Zc:__cplusplus', language: 'cpp') +endif # libdl is "special", not like other dependencies -cpp_compiler = meson.get_compiler('cpp') dl_dep = cpp_compiler.find_library('dl', required: false) thread_dep = dependency('threads') diff --git a/src/djinterop/enginelibrary/el_track_impl.cpp b/src/djinterop/enginelibrary/el_track_impl.cpp index 3ab3d7e..6356dc7 100644 --- a/src/djinterop/enginelibrary/el_track_impl.cpp +++ b/src/djinterop/enginelibrary/el_track_impl.cpp @@ -504,8 +504,8 @@ void el_track_impl::set_import_info( if (import_info) { set_cell("isExternalTrack", 1); - set_cell("uuidOfExternalDatabase", import_info->external_db_uuid()); - set_cell("idTrackInExternalDatabase", import_info->external_track_id()); + set_cell("uuidOfExternalDatabase", import_info->external_db_uuid); + set_cell("idTrackInExternalDatabase", import_info->external_track_id); } else { diff --git a/src/djinterop/impl/track_impl.hpp b/src/djinterop/impl/track_impl.hpp index d4f086a..2279a78 100644 --- a/src/djinterop/impl/track_impl.hpp +++ b/src/djinterop/impl/track_impl.hpp @@ -29,7 +29,7 @@ namespace djinterop { class database; class track; -class track_import_info; +struct track_import_info; enum class musical_key; class track_impl diff --git a/src/djinterop/track.cpp b/src/djinterop/track.cpp index e7ae768..972f89b 100644 --- a/src/djinterop/track.cpp +++ b/src/djinterop/track.cpp @@ -39,35 +39,6 @@ using std::chrono::system_clock; namespace djinterop { -track_import_info::track_import_info() noexcept = default; - -track_import_info::track_import_info( - std::string external_db_uuid, int64_t external_track_id) noexcept - : external_db_uuid_{std::move(external_db_uuid)}, - external_track_id_{external_track_id} -{ -} - -std::string& track_import_info::external_db_uuid() -{ - return external_db_uuid_; -} - -const std::string& track_import_info::external_db_uuid() const -{ - return external_db_uuid_; -} - -int64_t& track_import_info::external_track_id() -{ - return external_track_id_; -} - -const int64_t& track_import_info::external_track_id() const -{ - return external_track_id_; -} - track::track(const track& other) noexcept = default; track::~track() = default; diff --git a/src/meson.build b/src/meson.build index e730244..a7a697b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -24,13 +24,33 @@ sources = [ # Dependencies required by the main library. core_deps = [thread_dep, dl_dep, sqlite3_dep, zlib_dep, boost_dep] +if cpp_compiler.get_id() == 'msvc' + # Boost UUID on Windows uses bcrypt for random UUID generation. + bcrypt_dep = cpp_compiler.find_library('bcrypt') + core_deps += [bcrypt_dep] +endif + # Used by unit tests to reference internal classes. internal_inc = include_directories('.') +# Set a compile-time definition that we are building the libdjinterop source. +# This information is needed in `config.hpp` to determine whether public symbols +# ought to be exported or imported. +building_library_args = ['-DDJINTEROP_SOURCE'] + +# Set hidden visibility arguments as required. +hidden_visibility_args = [] +if get_option('default_library') != 'static' + if cpp_compiler.has_argument('-fvisibility=hidden') + hidden_visibility_args = ['-fvisibility=hidden'] + endif +endif + djinterop_lib = library( 'djinterop', sources: sources, include_directories: inc, dependencies: core_deps, - install: true) + install: true, + cpp_args: building_library_args + hidden_visibility_args) diff --git a/test/enginelibrary/enginelibrary_test.cpp b/test/enginelibrary/enginelibrary_test.cpp new file mode 100644 index 0000000..b882244 --- /dev/null +++ b/test/enginelibrary/enginelibrary_test.cpp @@ -0,0 +1,58 @@ +/* + This file is part of libdjinterop. + + libdjinterop is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + libdjinterop is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with libdjinterop. If not, see <http://www.gnu.org/licenses/>. + */ + +#define BOOST_TEST_MODULE enginelibrary_test +#include <boost/test/included/unit_test.hpp> + +#include <djinterop/enginelibrary.hpp> + +namespace el = djinterop::enginelibrary; + + +BOOST_AUTO_TEST_CASE(operators_equality__various__expected) +{ + // Arrange/Act/Assert + BOOST_CHECK(el::version_1_6_0 == el::version_1_6_0); + BOOST_CHECK(el::version_1_7_1 == el::version_1_7_1); + BOOST_CHECK(!(el::version_1_6_0 == el::version_1_7_1)); + BOOST_CHECK(!(el::version_1_7_1 == el::version_1_6_0)); + BOOST_CHECK(el::version_1_6_0 != el::version_1_7_1); + BOOST_CHECK(el::version_1_7_1 != el::version_1_6_0); + BOOST_CHECK(!(el::version_1_6_0 != el::version_1_6_0)); + BOOST_CHECK(!(el::version_1_7_1 != el::version_1_7_1)); +} + +BOOST_AUTO_TEST_CASE(operators_ordering__various__expected) +{ + // Arrange/Act/Assert + BOOST_CHECK(el::version_1_6_0 <= el::version_1_6_0); + BOOST_CHECK(el::version_1_7_1 <= el::version_1_7_1); + BOOST_CHECK(el::version_1_6_0 <= el::version_1_7_1); + BOOST_CHECK(!(el::version_1_7_1 <= el::version_1_6_0)); + BOOST_CHECK(!(el::version_1_6_0 < el::version_1_6_0)); + BOOST_CHECK(!(el::version_1_7_1 < el::version_1_7_1)); + BOOST_CHECK(el::version_1_6_0 < el::version_1_7_1); + BOOST_CHECK(!(el::version_1_7_1 < el::version_1_6_0)); + BOOST_CHECK(el::version_1_6_0 >= el::version_1_6_0); + BOOST_CHECK(el::version_1_7_1 >= el::version_1_7_1); + BOOST_CHECK(!(el::version_1_6_0 >= el::version_1_7_1)); + BOOST_CHECK(el::version_1_7_1 >= el::version_1_6_0); + BOOST_CHECK(!(el::version_1_6_0 > el::version_1_6_0)); + BOOST_CHECK(!(el::version_1_7_1 > el::version_1_7_1)); + BOOST_CHECK(!(el::version_1_6_0 > el::version_1_7_1)); + BOOST_CHECK(el::version_1_7_1 > el::version_1_6_0); +} diff --git a/test/enginelibrary/schema_test.cpp b/test/enginelibrary/schema_test.cpp deleted file mode 100644 index e7d7f89..0000000 --- a/test/enginelibrary/schema_test.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - This file is part of libdjinterop. - - libdjinterop is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - libdjinterop is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with libdjinterop. If not, see <http://www.gnu.org/licenses/>. - */ - -#define BOOST_TEST_MODULE schema_test -#include <boost/test/included/unit_test.hpp> - -#include <cstdio> -#include <iostream> - -#include <sqlite_modern_cpp.h> -#include <boost/filesystem.hpp> - -#include <djinterop/enginelibrary.hpp> -#include <djinterop/enginelibrary/schema.hpp> -#include <djinterop/semantic_version.hpp> - -#define STRINGIFY(x) STRINGIFY_(x) -#define STRINGIFY_(x) #x - -namespace el = djinterop::enginelibrary; -namespace fs = boost::filesystem; -using namespace std; - -const std::string sample_path{STRINGIFY(TESTDATA_DIR) "/el1"}; - -static fs::path create_temp_dir() -{ - fs::path temp_dir{fs::temp_directory_path()}; - temp_dir /= fs::unique_path(); - if (!fs::create_directory(temp_dir)) - { - throw std::runtime_error{"Failed to create tmp_dir"}; - } - std::cout << "Created temp dir at " << temp_dir.string() << std::endl; - return temp_dir; -} - -static void remove_temp_dir(const fs::path &temp_dir) -{ - fs::remove_all(temp_dir); - std::cout << "Removed temp dir at " << temp_dir.string() << std::endl; -} - -BOOST_AUTO_TEST_CASE(operators_equality__various__expected) -{ - // Arrange/Act/Assert - BOOST_CHECK(el::version_1_6_0 == el::version_1_6_0); - BOOST_CHECK(el::version_1_7_1 == el::version_1_7_1); - BOOST_CHECK(!(el::version_1_6_0 == el::version_1_7_1)); - BOOST_CHECK(!(el::version_1_7_1 == el::version_1_6_0)); - BOOST_CHECK(el::version_1_6_0 != el::version_1_7_1); - BOOST_CHECK(el::version_1_7_1 != el::version_1_6_0); - BOOST_CHECK(!(el::version_1_6_0 != el::version_1_6_0)); - BOOST_CHECK(!(el::version_1_7_1 != el::version_1_7_1)); -} - -BOOST_AUTO_TEST_CASE(operators_ordering__various__expected) -{ - // Arrange/Act/Assert - BOOST_CHECK(el::version_1_6_0 <= el::version_1_6_0); - BOOST_CHECK(el::version_1_7_1 <= el::version_1_7_1); - BOOST_CHECK(el::version_1_6_0 <= el::version_1_7_1); - BOOST_CHECK(!(el::version_1_7_1 <= el::version_1_6_0)); - BOOST_CHECK(!(el::version_1_6_0 < el::version_1_6_0)); - BOOST_CHECK(!(el::version_1_7_1 < el::version_1_7_1)); - BOOST_CHECK(el::version_1_6_0 < el::version_1_7_1); - BOOST_CHECK(!(el::version_1_7_1 < el::version_1_6_0)); - BOOST_CHECK(el::version_1_6_0 >= el::version_1_6_0); - BOOST_CHECK(el::version_1_7_1 >= el::version_1_7_1); - BOOST_CHECK(!(el::version_1_6_0 >= el::version_1_7_1)); - BOOST_CHECK(el::version_1_7_1 >= el::version_1_6_0); - BOOST_CHECK(!(el::version_1_6_0 > el::version_1_6_0)); - BOOST_CHECK(!(el::version_1_7_1 > el::version_1_7_1)); - BOOST_CHECK(!(el::version_1_6_0 > el::version_1_7_1)); - BOOST_CHECK(el::version_1_7_1 > el::version_1_6_0); -} - -BOOST_AUTO_TEST_CASE(verify_music_schema__db_at_1_0_0__verified) -{ - // Arrange - sqlite::database db{sample_path + "/m.db"}; - - // Act - auto version = el::verify_music_schema(db); - - // Assert - BOOST_CHECK_EQUAL(version, el::version_1_6_0); -} - -BOOST_AUTO_TEST_CASE(verify_performance_schema__db_at_1_0_0__verified) -{ - // Arrange - sqlite::database db{sample_path + "/p.db"}; - - // Act - auto version = el::verify_performance_schema(db); - - // Assert - BOOST_CHECK_EQUAL(version, el::version_1_6_0); -} - -BOOST_AUTO_TEST_CASE(create_music_schema__version_1_6_0__creates_verified) -{ - // Arrange - auto temp_dir = create_temp_dir(); - auto db_path = temp_dir / "m.db"; - sqlite::database db{":memory:"}; - db << "ATTACH ? as 'music'" << db_path.c_str(); - - // Act - el::create_music_schema(db, el::version_1_6_0); - - // Assert - el::verify_music_schema(db); - fs::remove_all(temp_dir); -} - -BOOST_AUTO_TEST_CASE(create_performance_schema__version_1_6_0__creates_verified) -{ - // Arrange - auto temp_dir = create_temp_dir(); - auto db_path = temp_dir / "p.db"; - sqlite::database db{":memory:"}; - db << "ATTACH ? as 'perfdata'" << db_path.c_str(); - - // Act - el::create_performance_schema(db, el::version_1_6_0); - - // Assert - el::verify_performance_schema(db); - remove_temp_dir(temp_dir); -} - -BOOST_AUTO_TEST_CASE(create_music_schema__version_1_7_1__creates_verified) -{ - // Arrange - auto temp_dir = create_temp_dir(); - auto db_path = temp_dir / "m.db"; - sqlite::database db{":memory:"}; - db << "ATTACH ? as 'music'" << db_path.c_str(); - - // Act - el::create_music_schema(db, el::version_1_7_1); - - // Assert - el::verify_music_schema(db); - fs::remove_all(temp_dir); -} - -BOOST_AUTO_TEST_CASE(create_performance_schema__version_1_7_1__creates_verified) -{ - // Arrange - auto temp_dir = create_temp_dir(); - auto db_path = temp_dir / "p.db"; - sqlite::database db{":memory:"}; - db << "ATTACH ? as 'perfdata'" << db_path.c_str(); - - // Act - el::create_performance_schema(db, el::version_1_7_1); - - // Assert - el::verify_performance_schema(db); - remove_temp_dir(temp_dir); -} diff --git a/test/enginelibrary/track_test.cpp b/test/enginelibrary/track_test.cpp index d2b7543..095b0cb 100644 --- a/test/enginelibrary/track_test.cpp +++ b/test/enginelibrary/track_test.cpp @@ -172,9 +172,9 @@ static void check_track_2(djinterop::track &t) c::system_clock::period::num / c::system_clock::period::den, 1518825600); BOOST_CHECK_EQUAL( - t.import_info()->external_db_uuid(), + t.import_info()->external_db_uuid, "e535b170-26ef-4f30-8cb2-5b9fa4c2a27f"); - BOOST_CHECK_EQUAL(t.import_info()->external_track_id(), 123); + BOOST_CHECK_EQUAL(t.import_info()->external_track_id, 123); BOOST_CHECK(!t.album_art_id()); } diff --git a/test/meson.build b/test/meson.build index f2e6bd0..98bb185 100644 --- a/test/meson.build +++ b/test/meson.build @@ -6,24 +6,18 @@ test_deps = [boost_test_dep, sqlite3_dep] engine_library_test_names = [ 'crate_test', 'database_test', + 'enginelibrary_test', 'performance_data_test', - 'schema_test', 'track_test' ] -# Don't run unit tests under MSVC for now, as there are linker errors -# which I don't have time to investigate properly. -# (Briefly, MSVC looks for djinterop.lib and doesn't use libdjinterop.a) -compiler = meson.get_compiler('cpp') -if compiler.get_id() != 'msvc' - foreach test_name : engine_library_test_names - exe = executable( - 'el_' + test_name, - 'enginelibrary/' + test_name + '.cpp', - cpp_args : ['-DTESTDATA_DIR=' + testdata_dir], - include_directories : [inc, internal_inc], - dependencies : test_deps, - link_with : djinterop_lib) - test(test_name, exe) - endforeach -endif +foreach test_name : engine_library_test_names + exe = executable( + 'el_' + test_name, + 'enginelibrary/' + test_name + '.cpp', + cpp_args : ['-DTESTDATA_DIR=' + testdata_dir], + include_directories : [inc, internal_inc], + dependencies : test_deps, + link_with : djinterop_lib) + test(test_name, exe) +endforeach |