diff options
author | David Robillard <d@drobilla.net> | 2022-12-13 01:16:41 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-12-14 18:04:27 -0500 |
commit | 4b56cdf7a925dafd5e4ac085874d2afe294ec456 (patch) | |
tree | b0fd7ab1b58c1cc4eb4ec0f211b3221522ea2a7f /tests | |
parent | f6ee1ce7bb45d0f6267b2dad61f6b87c79a5906c (diff) | |
download | ingen-4b56cdf7a925dafd5e4ac085874d2afe294ec456.tar.gz ingen-4b56cdf7a925dafd5e4ac085874d2afe294ec456.tar.bz2 ingen-4b56cdf7a925dafd5e4ac085874d2afe294ec456.zip |
Use std::filesystem and std::make_unique
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ingen_test.cpp | 9 | ||||
-rw-r--r-- | tests/meson.build | 1 | ||||
-rw-r--r-- | tests/tst_FilePath.cpp | 108 |
3 files changed, 5 insertions, 113 deletions
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index d6ebee26..9dfc3641 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -29,7 +29,6 @@ #include "ingen/URI.hpp" #include "ingen/URIMap.hpp" #include "ingen/World.hpp" -#include "ingen/filesystem.hpp" #include "ingen/fmt.hpp" #include "ingen/memory.hpp" #include "ingen/runtime_paths.hpp" @@ -42,9 +41,11 @@ #include <cstdint> #include <cstdlib> #include <exception> +#include <filesystem> #include <iostream> #include <map> #include <memory> +#include <sstream> #include <string> #include <utility> @@ -202,7 +203,7 @@ run(int argc, char** argv) auto r = world->store()->find(raul::Path("/")); const std::string base = run_path.stem(); const std::string out_name = base.substr(0, base.find('.')) + ".out.ingen"; - const FilePath out_path = filesystem::current_path() / out_name; + const FilePath out_path = std::filesystem::current_path() / out_name; world->serialiser()->write_bundle(r->second, URI(out_path)); // Undo every event (makes the graph identical to the original) @@ -214,7 +215,7 @@ run(int argc, char** argv) // Save completely undone graph r = world->store()->find(raul::Path("/")); const std::string undo_name = base.substr(0, base.find('.')) + ".undo.ingen"; - const FilePath undo_path = filesystem::current_path() / undo_name; + const FilePath undo_path = std::filesystem::current_path() / undo_name; world->serialiser()->write_bundle(r->second, URI(undo_path)); // Redo every event (makes the graph identical to the pre-undo output) @@ -226,7 +227,7 @@ run(int argc, char** argv) // Save completely redone graph r = world->store()->find(raul::Path("/")); const std::string redo_name = base.substr(0, base.find('.')) + ".redo.ingen"; - const FilePath redo_path = filesystem::current_path() / redo_name; + const FilePath redo_path = std::filesystem::current_path() / redo_name; world->serialiser()->write_bundle(r->second, URI(redo_path)); serd_env_free(env); diff --git a/tests/meson.build b/tests/meson.build index a9bf5725..50b78624 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,7 +6,6 @@ ############## unit_tests = [ - 'FilePath', ] foreach test : unit_tests diff --git a/tests/tst_FilePath.cpp b/tests/tst_FilePath.cpp deleted file mode 100644 index 75744f46..00000000 --- a/tests/tst_FilePath.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2018 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "test_utils.hpp" - -#include "ingen/FilePath.hpp" -#include "ingen/fmt.hpp" - -#include <boost/utility/string_view_fwd.hpp> - -#include <string> - -using ingen::FilePath; -using ingen::fmt; - -int -main(int, char**) -{ - EXPECT_EQ(FilePath("/").parent_path(), FilePath("/")); - - EXPECT_TRUE(FilePath("/abs").is_absolute()); - EXPECT_FALSE(FilePath("/abs").is_relative()); - EXPECT_EQ(FilePath("/abs").root_name(), FilePath()); - EXPECT_EQ(FilePath("/abs").root_directory(), FilePath("/")); - EXPECT_EQ(FilePath("/abs").root_path(), FilePath("/")); - EXPECT_EQ(FilePath("/abs").relative_path(), FilePath("abs")); - EXPECT_EQ(FilePath("/abs").parent_path(), FilePath("/")); - EXPECT_EQ(FilePath("/abs").filename(), FilePath("abs")); - EXPECT_EQ(FilePath("/abs").stem(), FilePath("abs")); - EXPECT_EQ(FilePath("/abs").extension(), FilePath()); - - EXPECT_FALSE(FilePath("rel").is_absolute()); - EXPECT_TRUE(FilePath("rel").is_relative()); - EXPECT_EQ(FilePath("rel").root_name(), FilePath()); - EXPECT_EQ(FilePath("rel").root_directory(), FilePath()); - EXPECT_EQ(FilePath("rel").root_path(), FilePath()); - EXPECT_EQ(FilePath("rel").relative_path(), FilePath()); - EXPECT_EQ(FilePath("rel").parent_path(), FilePath()); - EXPECT_EQ(FilePath("rel").filename(), "rel"); - EXPECT_EQ(FilePath("rel").stem(), "rel"); - EXPECT_EQ(FilePath("rel").extension(), FilePath()); - - EXPECT_FALSE(FilePath("file.txt").is_absolute()); - EXPECT_TRUE(FilePath("file.txt").is_relative()); - EXPECT_EQ(FilePath("file.txt").filename(), "file.txt"); - EXPECT_EQ(FilePath("file.txt").stem(), "file"); - EXPECT_EQ(FilePath("file.txt").extension(), ".txt"); - - EXPECT_TRUE(FilePath("/abs/file.txt").is_absolute()); - EXPECT_FALSE(FilePath("/abs/file.txt").is_relative()); - EXPECT_EQ(FilePath("/abs/file.txt").filename(), "file.txt"); - EXPECT_EQ(FilePath("/abs/file.txt").stem(), "file"); - EXPECT_EQ(FilePath("/abs/file.txt").extension(), ".txt"); - - EXPECT_FALSE(FilePath("rel/file.txt").is_absolute()); - EXPECT_TRUE(FilePath("rel/file.txt").is_relative()); - EXPECT_EQ(FilePath("rel/file.txt").filename(), "file.txt"); - EXPECT_EQ(FilePath("rel/file.txt").stem(), "file"); - EXPECT_EQ(FilePath("rel/file.txt").extension(), ".txt"); - - FilePath path("/x"); - EXPECT_EQ(path, "/x"); - path = std::string("/a"); - EXPECT_EQ(path, "/a"); - - path /= FilePath("b"); - EXPECT_EQ(path, "/a/b"); - - path += FilePath("ar"); - EXPECT_EQ(path, "/a/bar"); - - path += std::string("/c"); - EXPECT_EQ(path, "/a/bar/c"); - - path += "a"; - EXPECT_EQ(path, "/a/bar/ca"); - - path += 'r'; - EXPECT_EQ(path, "/a/bar/car"); - - path += boost::string_view("/d"); - EXPECT_EQ(path, "/a/bar/car/d"); - - const FilePath apple("apple"); - const FilePath zebra("zebra"); - EXPECT_TRUE(apple == apple); - EXPECT_TRUE(apple != zebra); - EXPECT_TRUE(apple < zebra); - EXPECT_TRUE(apple <= zebra); - EXPECT_TRUE(apple <= apple); - EXPECT_TRUE(zebra > apple); - EXPECT_TRUE(zebra >= apple); - EXPECT_TRUE(zebra >= zebra); - return 0; -} |