summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_filespec_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_filespec_unittest.cpp')
-rw-r--r--core/fpdfdoc/cpdf_filespec_unittest.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 7e2975c5f0..8d151c9dd8 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -48,11 +48,11 @@ TEST(cpdf_filespec, EncodeDecodeFileName) {
#endif
};
for (const auto& data : test_data) {
- CFX_WideString encoded_str = CPDF_FileSpec::EncodeFileName(data.input);
- EXPECT_TRUE(encoded_str == data.expected);
+ EXPECT_STREQ(data.expected,
+ CPDF_FileSpec::EncodeFileName(data.input).c_str());
// DecodeFileName is the reverse procedure of EncodeFileName.
- CFX_WideString decoded_str = CPDF_FileSpec::DecodeFileName(data.expected);
- EXPECT_TRUE(decoded_str == data.input);
+ EXPECT_STREQ(data.input,
+ CPDF_FileSpec::DecodeFileName(data.expected).c_str());
}
}
@@ -73,9 +73,7 @@ TEST(cpdf_filespec, GetFileName) {
};
auto str_obj = pdfium::MakeUnique<CPDF_String>(nullptr, test_data.input);
CPDF_FileSpec file_spec(str_obj.get());
- CFX_WideString file_name;
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.expected);
+ EXPECT_STREQ(test_data.expected, file_spec.GetFileName().c_str());
}
{
// Dictionary object.
@@ -104,25 +102,22 @@ TEST(cpdf_filespec, GetFileName) {
const char* const keywords[5] = {"Unix", "Mac", "DOS", "F", "UF"};
auto dict_obj = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_FileSpec file_spec(dict_obj.get());
- CFX_WideString file_name;
+ EXPECT_TRUE(file_spec.GetFileName().IsEmpty());
for (int i = 0; i < 5; ++i) {
dict_obj->SetNewFor<CPDF_String>(keywords[i], test_data[i].input);
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data[i].expected);
+ EXPECT_STREQ(test_data[i].expected, file_spec.GetFileName().c_str());
}
// With all the former fields and 'FS' field suggests 'URL' type.
dict_obj->SetNewFor<CPDF_String>("FS", "URL", false);
- EXPECT_TRUE(file_spec.GetFileName(&file_name));
// Url string is not decoded.
- EXPECT_TRUE(file_name == test_data[4].input);
+ EXPECT_STREQ(test_data[4].input, file_spec.GetFileName().c_str());
}
{
// Invalid object.
auto name_obj = pdfium::MakeUnique<CPDF_Name>(nullptr, "test.pdf");
CPDF_FileSpec file_spec(name_obj.get());
- CFX_WideString file_name;
- EXPECT_FALSE(file_spec.GetFileName(&file_name));
+ EXPECT_TRUE(file_spec.GetFileName().IsEmpty());
}
}
@@ -144,25 +139,19 @@ TEST(cpdf_filespec, SetFileName) {
CPDF_FileSpec file_spec1(str_obj.get());
file_spec1.SetFileName(test_data.input);
// Check internal object value.
- CFX_ByteString str = CFX_ByteString::FromUnicode(test_data.expected);
- EXPECT_TRUE(str == str_obj->GetString());
+ EXPECT_STREQ(test_data.expected, str_obj->GetUnicodeText().c_str());
// Check we can get the file name back.
- CFX_WideString file_name;
- EXPECT_TRUE(file_spec1.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.input);
+ EXPECT_STREQ(test_data.input, file_spec1.GetFileName().c_str());
// Dictionary object.
auto dict_obj = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_FileSpec file_spec2(dict_obj.get());
file_spec2.SetFileName(test_data.input);
// Check internal object value.
- file_name = dict_obj->GetUnicodeTextFor("F");
- EXPECT_TRUE(file_name == test_data.expected);
- file_name = dict_obj->GetUnicodeTextFor("UF");
- EXPECT_TRUE(file_name == test_data.expected);
+ EXPECT_STREQ(test_data.expected, dict_obj->GetUnicodeTextFor("F").c_str());
+ EXPECT_STREQ(test_data.expected, dict_obj->GetUnicodeTextFor("UF").c_str());
// Check we can get the file name back.
- EXPECT_TRUE(file_spec2.GetFileName(&file_name));
- EXPECT_TRUE(file_name == test_data.input);
+ EXPECT_STREQ(test_data.input, file_spec2.GetFileName().c_str());
}
TEST(cpdf_filespec, GetFileStream) {