Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_OSX_DEPLOYMENT_TARGET "13.3")

if(MSVC)
add_compile_options(/utf-8)
endif()

# Set RPATH settings for shared library discovery
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
Expand Down
2 changes: 1 addition & 1 deletion src/c2pa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace c2pa
/// converts a filesystem::path to a string in utf-8 format
inline std::string path_to_string(const filesystem::path &source_path)
{
return reinterpret_cast<const char *>(source_path.u8string().c_str());
return source_path.u8string();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cleaning up a bit. This doesn't affect the results of the workflows.

}

/// Reads a file and returns the manifest json as a C2pa::String.
Expand Down
Binary file added tests/fixtures/CÖÄ_.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 22 additions & 8 deletions tests/reader.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include <filesystem>
#include <fstream>

using nlohmann::json;
namespace fs = std::filesystem;

TEST(Reader, StreamWithManifest)
{
TEST(Reader, StreamWithManifest) {
fs::path current_dir = fs::path(__FILE__).parent_path();
fs::path test_file = current_dir / "../tests/fixtures/C.jpg";

fs::path test_file = current_dir.parent_path() / "tests" / "fixtures" / L"CÖÄ_.jpg";
ASSERT_TRUE(std::filesystem::exists(test_file)) << "Test file does not exist: " << test_file;

// read the new manifest and display the JSON
std::ifstream file_stream(test_file, std::ios::binary);
ASSERT_TRUE(file_stream.is_open()) << "Failed to open file: " << test_file;
Expand Down Expand Up @@ -59,17 +60,18 @@ class RemoteUrlTests
: public ::testing::TestWithParam<std::tuple<std::string, bool>> {
public:
static c2pa::Reader reader_from_fixture(const std::string &file_name) {
auto current_dir = fs::path(__FILE__).parent_path();
auto fixture = current_dir / "../tests/fixtures" / file_name;
return {fixture};
auto current_dir = fs::path(__FILE__).parent_path();
auto fixture = current_dir / "../tests/fixtures" / file_name;
std::ifstream stream(fixture, std::ios::binary);
return { "image/jpeg", stream };
}
};

INSTANTIATE_TEST_SUITE_P(ReaderRemoteUrlTests, RemoteUrlTests,
::testing::Values(
// (fixture filename, is_remote_manifest)
std::make_tuple("cloud.jpg", true),
std::make_tuple("C_with_CAWG_data.jpg", false)));
std::make_tuple("C.jpg", false)));

TEST_P(RemoteUrlTests, RemoteUrl) {
auto reader = reader_from_fixture(std::get<0>(GetParam()));
Expand All @@ -83,6 +85,18 @@ TEST_P(RemoteUrlTests, IsEmbeddedTest) {
EXPECT_EQ(reader.is_embedded(), !expected_is_remote);
}

TEST(Reader, HasManifestUtf8Path) {
auto current_dir = fs::path(__FILE__).parent_path();
auto test_file = current_dir.parent_path() / "tests" / "fixtures" / L"CÖÄ_.jpg";
ASSERT_TRUE(std::filesystem::exists(test_file)) << "Test file does not exist: " << test_file;

std::ifstream stream(test_file, std::ios::binary);
auto reader = c2pa::Reader("image/jpeg", stream);

EXPECT_FALSE(reader.remote_url());
EXPECT_TRUE(reader.is_embedded());
}

/* remove this until we resolve CAWG Identity testing
TEST(Reader, FileWithCawgIdentityManifest)
{
Expand Down
Loading