aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/cache.cpp10
-rw-r--r--test/fslock.cpp11
-rw-r--r--test/itemlistformaction.cpp42
-rw-r--r--test/queuemanager.cpp4
-rw-r--r--test/test_helpers/tempfile.cpp4
-rw-r--r--test/test_helpers/tempfile.h5
-rw-r--r--test/utils.cpp6
7 files changed, 39 insertions, 43 deletions
diff --git a/test/cache.cpp b/test/cache.cpp
index 80d931a4..093a4891 100644
--- a/test/cache.cpp
+++ b/test/cache.cpp
@@ -1,5 +1,3 @@
-#define ENABLE_IMPLICIT_FILEPATH_CONVERSIONS
-
#include "cache.h"
#include <memory>
@@ -140,16 +138,16 @@ TEST_CASE("Last-Modified and ETag values are also stored in DB if feed was not y
"[Cache]")
{
ConfigContainer cfg;
- Cache rsscache(":memory:", cfg);
+ auto rsscache = Cache::in_memory(cfg);
const std::string feedurl = "http://example.com/feed.xml";
const time_t lastmodified = 42;
const std::string etag = "abc";
- rsscache.update_lastmodified(feedurl, lastmodified, etag);
+ rsscache->update_lastmodified(feedurl, lastmodified, etag);
time_t output_lastmodified{};
std::string output_etag;
- rsscache.fetch_lastmodified(feedurl, output_lastmodified, output_etag);
+ rsscache->fetch_lastmodified(feedurl, output_lastmodified, output_etag);
REQUIRE(output_lastmodified == lastmodified);
REQUIRE(output_etag == etag);
@@ -1001,7 +999,7 @@ TEST_CASE(
// can't be done by direct assignment because sqlite3_open doesn't
// return that pointer)
sqlite3* dbptr = nullptr;
- int error = sqlite3_open(dbfile.get_path().c_str(), &dbptr);
+ int error = sqlite3_open(dbfile.get_path().to_locale_string().c_str(), &dbptr);
REQUIRE(error == SQLITE_OK);
db.reset(dbptr);
dbptr = nullptr;
diff --git a/test/fslock.cpp b/test/fslock.cpp
index 1c1dcb6a..883c4b0e 100644
--- a/test/fslock.cpp
+++ b/test/fslock.cpp
@@ -95,7 +95,8 @@ TEST_CASE("try_lock() returns an error if lock-file permissions or location are
GIVEN("A lock file which does not grant write access") {
const test_helpers::TempFile lock_location;
- const int fd = ::open(lock_location.get_path().c_str(), O_RDWR | O_CREAT, 0400);
+ const int fd = ::open(lock_location.get_path().to_locale_string().c_str(),
+ O_RDWR | O_CREAT, 0400);
::close(fd);
THEN("try_lock() will fail and return pid == 0") {
@@ -144,7 +145,7 @@ TEST_CASE("try_lock() succeeds if lock file location is valid and not locked by
REQUIRE(lock.try_lock(lock_location.get_path(), pid, error_message));
SECTION("The lock file exists after a call to try_lock()") {
- REQUIRE(0 == ::access(lock_location.get_path().c_str(), F_OK));
+ REQUIRE(0 == ::access(lock_location.get_path().to_locale_string().c_str(), F_OK));
}
SECTION("Calling try_lock() a second time for the same location succeeds") {
@@ -154,10 +155,10 @@ TEST_CASE("try_lock() succeeds if lock file location is valid and not locked by
SECTION("Calling try_lock() a second time with a different location succeeds and cleans up old lock file") {
const test_helpers::TempFile new_lock_location;
- REQUIRE(0 == ::access(lock_location.get_path().c_str(), F_OK));
+ REQUIRE(0 == ::access(lock_location.get_path().to_locale_string().c_str(), F_OK));
REQUIRE(lock.try_lock(new_lock_location.get_path(), pid, error_message));
- REQUIRE(0 != ::access(lock_location.get_path().c_str(), F_OK));
- REQUIRE(0 == ::access(new_lock_location.get_path().c_str(), F_OK));
+ REQUIRE(0 != ::access(lock_location.get_path().to_locale_string().c_str(), F_OK));
+ REQUIRE(0 == ::access(new_lock_location.get_path().to_locale_string().c_str(), F_OK));
}
}
diff --git a/test/itemlistformaction.cpp b/test/itemlistformaction.cpp
index 2605075d..662a6f97 100644
--- a/test/itemlistformaction.cpp
+++ b/test/itemlistformaction.cpp
@@ -1,5 +1,3 @@
-#define ENABLE_IMPLICIT_FILEPATH_CONVERSIONS
-
#include "itemlistformaction.h"
#include <fstream>
@@ -43,7 +41,7 @@ TEST_CASE("OP_OPEN displays article using an external pager",
RegexManager rxman;
auto rsscache = Cache::in_memory(cfg);
- cfg.set_configvalue("pager", "cat %f > " + pagerfile.get_path());
+ cfg.set_configvalue("pager", "cat %f > " + pagerfile.get_path().to_locale_string());
std::shared_ptr<RssFeed> feed = std::make_shared<RssFeed>(rsscache.get(), "");
@@ -120,7 +118,7 @@ TEST_CASE(
std::string line;
ConfigContainer cfg;
- cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path());
+ cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
FilterContainer filters;
@@ -139,7 +137,7 @@ TEST_CASE(
itemlist.set_feed(feed);
const std::vector<std::string> args;
itemlist.process_op(OP_OPENBROWSER_AND_MARK, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
REQUIRE(std::getline(browserFileStream, line));
REQUIRE(line == test_url);
@@ -192,7 +190,7 @@ TEST_CASE("OP_OPENINBROWSER passes the url to the browser",
std::string line;
ConfigContainer cfg;
- cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path());
+ cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
FilterContainer filters;
@@ -210,7 +208,7 @@ TEST_CASE("OP_OPENINBROWSER passes the url to the browser",
itemlist.set_feed(feed);
const std::vector<std::string> args;
itemlist.process_op(OP_OPENINBROWSER, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
REQUIRE(std::getline(browserFileStream, line));
REQUIRE(line == test_url);
@@ -227,7 +225,7 @@ TEST_CASE("OP_OPENINBROWSER_NONINTERACTIVE passes the url to the browser",
std::string line;
ConfigContainer cfg;
- cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path());
+ cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
FilterContainer filters;
@@ -245,7 +243,7 @@ TEST_CASE("OP_OPENINBROWSER_NONINTERACTIVE passes the url to the browser",
itemlist.set_feed(feed);
const std::vector<std::string> args;
itemlist.process_op(newsboat::OP_OPENINBROWSER_NONINTERACTIVE, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
REQUIRE(std::getline(browserFileStream, line));
REQUIRE(line == test_url);
@@ -264,7 +262,7 @@ TEST_CASE("OP_OPENALLUNREADINBROWSER passes the url list to the browser",
int itemCount = 6;
ConfigContainer cfg;
- cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path());
+ cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
FilterContainer filters;
@@ -296,7 +294,7 @@ TEST_CASE("OP_OPENALLUNREADINBROWSER passes the url list to the browser",
const std::vector<std::string> args;
itemlist.process_op(OP_OPENALLUNREADINBROWSER, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
openedItemsCount = 0;
if (browserFileStream.is_open()) {
while (std::getline(browserFileStream, line)) {
@@ -320,7 +318,7 @@ TEST_CASE("OP_OPENALLUNREADINBROWSER passes the url list to the browser",
const std::vector<std::string> args;
itemlist.process_op(OP_OPENALLUNREADINBROWSER, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
if (browserFileStream.is_open()) {
while (std::getline(browserFileStream, line)) {
INFO("Each URL should be present exactly once. "
@@ -350,7 +348,7 @@ TEST_CASE(
const unsigned int itemCount = 6;
ConfigContainer cfg;
- cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path());
+ cfg.set_configvalue("browser", "echo %u >> " + browserfile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
FilterContainer filters;
@@ -382,7 +380,7 @@ TEST_CASE(
const std::vector<std::string> args;
itemlist.process_op(OP_OPENALLUNREADINBROWSER_AND_MARK, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
if (browserFileStream.is_open()) {
while (std::getline(browserFileStream, line)) {
INFO("Each URL should be present exactly once. "
@@ -407,7 +405,7 @@ TEST_CASE(
const std::vector<std::string> args;
itemlist.process_op(OP_OPENALLUNREADINBROWSER_AND_MARK, args);
- std::ifstream browserFileStream(browserfile.get_path());
+ std::ifstream browserFileStream(browserfile.get_path().to_locale_string());
if (browserFileStream.is_open()) {
while (std::getline(browserFileStream, line)) {
INFO("Each URL should be present exactly once. "
@@ -462,7 +460,7 @@ TEST_CASE("OP_SHOWURLS shows the article's properties", "[ItemListFormAction]")
feed->add_item(item);
itemlist.set_feed(feed);
cfg.set_configvalue(
- "external-url-viewer", "tee > " + urlFile.get_path());
+ "external-url-viewer", "tee > " + urlFile.get_path().to_locale_string());
const std::vector<std::string> args;
REQUIRE_NOTHROW(itemlist.process_op(OP_SHOWURLS, args));
@@ -524,12 +522,12 @@ TEST_CASE("OP_BOOKMARK pipes articles url and title to bookmark-command",
itemlist.set_feed(feed);
cfg.set_configvalue(
- "bookmark-cmd", "echo > " + bookmarkFile.get_path());
+ "bookmark-cmd", "echo > " + bookmarkFile.get_path().to_locale_string());
bookmark_args.push_back(extra_arg);
auto checkOutput = [&] {
- std::ifstream browserFileStream(bookmarkFile.get_path());
+ std::ifstream browserFileStream(bookmarkFile.get_path().to_locale_string());
REQUIRE(std::getline(browserFileStream, line));
REQUIRE(line ==
@@ -622,7 +620,7 @@ TEST_CASE("OP_SAVE writes an article's attributes to the specified file",
RegexManager rxman;
std::vector<std::string> op_args;
- op_args.push_back(saveFile.get_path());
+ op_args.push_back(saveFile.get_path().to_locale_string());
const std::string test_url = "http://test_url";
std::string test_title = "Article Title";
@@ -735,7 +733,7 @@ TEST_CASE("Navigate back and forth using OP_NEXT and OP_PREV",
newsboat::View v(&c);
ConfigContainer cfg;
cfg.set_configvalue(
- "external-url-viewer", "tee > " + articleFile.get_path());
+ "external-url-viewer", "tee > " + articleFile.get_path().to_locale_string());
auto rsscache = Cache::in_memory(cfg);
std::string line;
@@ -765,7 +763,7 @@ TEST_CASE("Navigate back and forth using OP_NEXT and OP_PREV",
REQUIRE_NOTHROW(itemlist->process_op(OP_NEXT, args));
itemlist->process_op(OP_SHOWURLS, args);
- std::ifstream fileStream(articleFile.get_path());
+ std::ifstream fileStream(articleFile.get_path().to_locale_string());
std::getline(fileStream, line);
REQUIRE(line == prefix_title + second_article_title);
@@ -828,7 +826,7 @@ TEST_CASE("OP_PIPE_TO pipes an article's content to an external command",
RegexManager rxman;
std::vector<std::string> op_args;
- op_args.push_back("tee > " + articleFile.get_path());
+ op_args.push_back("tee > " + articleFile.get_path().to_locale_string());
const std::string test_url = "http://test_url";
std::string test_title = "Article Title";
diff --git a/test/queuemanager.cpp b/test/queuemanager.cpp
index 83a02f5d..95462072 100644
--- a/test/queuemanager.cpp
+++ b/test/queuemanager.cpp
@@ -230,7 +230,7 @@ SCENARIO("enqueue_url() errors if the queue file can't be opened for writing",
THEN("the return value indicates the file couldn't be written to") {
REQUIRE(result.status == EnqueueStatus::QUEUE_FILE_OPEN_ERROR);
- REQUIRE(result.extra_info == queue_file.get_path());
+ REQUIRE(result.extra_info == queue_file.get_path().to_locale_string());
}
THEN("the item is NOT marked as enqueued") {
@@ -558,7 +558,7 @@ SCENARIO("autoenqueue() errors if the queue file can't be opened for writing",
THEN("the return value indicates the file couldn't be written to") {
REQUIRE(result.status == EnqueueStatus::QUEUE_FILE_OPEN_ERROR);
- REQUIRE(result.extra_info == queue_file.get_path());
+ REQUIRE(result.extra_info == queue_file.get_path().to_locale_string());
}
THEN("the item is NOT marked as enqueued") {
diff --git a/test/test_helpers/tempfile.cpp b/test/test_helpers/tempfile.cpp
index 9b7a63f6..cceb83cc 100644
--- a/test/test_helpers/tempfile.cpp
+++ b/test/test_helpers/tempfile.cpp
@@ -46,7 +46,7 @@ test_helpers::TempFile::~TempFile()
::unlink(filepath_str.c_str());
}
-const std::string test_helpers::TempFile::get_path() const
+newsboat::Filepath test_helpers::TempFile::get_path() const
{
- return filepath.to_locale_string();
+ return filepath;
}
diff --git a/test/test_helpers/tempfile.h b/test/test_helpers/tempfile.h
index 0ff0ac62..0e109b8f 100644
--- a/test/test_helpers/tempfile.h
+++ b/test/test_helpers/tempfile.h
@@ -1,8 +1,7 @@
#ifndef NEWSBOAT_TEST_HELPERS_TEMPFILE_H_
#define NEWSBOAT_TEST_HELPERS_TEMPFILE_H_
-#include <string>
-
+#include "filepath.h"
#include "maintempdir.h"
namespace test_helpers {
@@ -18,7 +17,7 @@ public:
~TempFile();
- const std::string get_path() const;
+ newsboat::Filepath get_path() const;
private:
MainTempDir tempdir;
diff --git a/test/utils.cpp b/test/utils.cpp
index def9ca69..5cc787b0 100644
--- a/test/utils.cpp
+++ b/test/utils.cpp
@@ -642,14 +642,14 @@ TEST_CASE("run_command() executes the given command with a given argument",
INFO("File shouldn't exist, because TempFile doesn't create it");
struct stat sb;
- const int result = ::stat(argument.c_str(), &sb);
+ const int result = ::stat(argument.to_locale_string().c_str(), &sb);
const int saved_errno = errno;
REQUIRE(result == -1);
REQUIRE(saved_errno == ENOENT);
}
- utils::run_command("touch", argument);
+ utils::run_command("touch", argument.to_locale_string());
struct stat sb;
int result = 0;
@@ -662,7 +662,7 @@ TEST_CASE("run_command() executes the given command with a given argument",
while (tries-- > 0) {
::usleep(10 * 1000);
- result = ::stat(argument.c_str(), &sb);
+ result = ::stat(argument.to_locale_string().c_str(), &sb);
if (result == 0) {
break;
}