diff options
Diffstat (limited to 'o3d/import/cross/tar_generator_test.cc')
-rw-r--r-- | o3d/import/cross/tar_generator_test.cc | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/o3d/import/cross/tar_generator_test.cc b/o3d/import/cross/tar_generator_test.cc index 0e45b8d..9403d62 100644 --- a/o3d/import/cross/tar_generator_test.cc +++ b/o3d/import/cross/tar_generator_test.cc @@ -63,15 +63,19 @@ const int kMagicOffset = 257; const int kUserNameOffset = 265; const int kGroupNameOffset = 297; +const char *kLongLink = "././@LongLink"; const char *kDirName1 = "test/apples/"; const char *kDirName2 = "test/oranges/"; const char *kFileName1 = "test/apples/file1"; const char *kFileName2 = "test/apples/file2"; const char *kFileName3 = "test/oranges/file3"; +const char *kFileName4 = + "ThisIsAFilenameLongerThen100CharsThisIsAFilenameLongerThen100Chars" + "ThisIsAFilenameLongerThen100CharsThisIsAFilenameLongerThen100Chars"; // The first file is less than one block in size const char *kFileContents1 = - "The cellphone is the world’s most ubiquitous computer.\n" + "The cellphone is the world most ubiquitous computer.\n" "The four billion cellphones in use around the globe carry personal\n" "information, provide access to the Web and are being used more and more\n" "to navigate the real world. And as cellphones change how we live,\n" @@ -87,11 +91,11 @@ const char *kFileContents2 = "levels since the credit crisis erupted. Financial shares were battered.\n" "And rattled investors clamored to buy rainy-day investments like gold\n" "and Treasury debt. It was a global wave of selling spurred by rising\n" - "worries about how banks, automakers — entire countries — would fare\n" + "worries about how banks, automakers entire countries would fare\n" "in a deepening global downturn.\n" - "'Nobody believes it’s going get better yet,' said Howard Silverblatt,\n" - "senior index analyst at Standard & Poor’s. 'Do you see that light at\n" - "the end of the tunnel? Any kind of light? Right now, it’s not there'\n" + "'Nobody believes it&'s going get better yet,' said Howard Silverblatt,\n" + "senior index analyst at Standard & Poors. 'Do you see that light at\n" + "the end of the tunnel? Any kind of light? Right now, it's not there'\n" "yet.\n"; // The 3rd file takes one block @@ -117,6 +121,10 @@ class CallbackClient : public StreamProcessor { VALIDATE_DIRECTORY_HEADER2, // 3rd file is in another directory VALIDATE_FILE_HEADER3, VALIDATE_FILE_DATA3, + VALIDATE_FILE_LONGNAME_HEADER4, // 4th file has a long name. + VALIDATE_FILE_LONGNAME_DATA4, + VALIDATE_FILE_HEADER4, + VALIDATE_FILE_DATA4, FINISHED }; @@ -213,6 +221,25 @@ int CallbackClient::ProcessBytes(MemoryReadStream *stream, ValidateData(memory_block_, kFileContents3); break; + case VALIDATE_FILE_LONGNAME_HEADER4: + ValidateHeader(memory_block_, kLongLink, strlen(kFileName4)); + break; + + case VALIDATE_FILE_LONGNAME_DATA4: + ValidateData(memory_block_, kFileName4); + break; + + case VALIDATE_FILE_HEADER4: { + String first_99_chars(kFileName4, 99); + ValidateHeader(memory_block_, first_99_chars.c_str(), + strlen(kFileContents3)); + break; + } + + case VALIDATE_FILE_DATA4: + ValidateData(memory_block_, kFileContents3); + break; + case FINISHED: break; } @@ -316,7 +343,7 @@ void CallbackClient::ValidateHeader(uint8 *header, // For now we only have directories '5' or normal files '0' int link_flag = header[kLinkFlagOffset]; - EXPECT_TRUE(link_flag == '0' || link_flag == '5'); + EXPECT_TRUE(link_flag == '0' || link_flag == '5' || link_flag == 'L'); EXPECT_EQ(0, strcmp((const char*)header + kMagicOffset, "ustar ")); @@ -357,20 +384,24 @@ TEST_F(TarGeneratorTest, CreateSimpleArchive) { const int kFileLength2 = strlen(kFileContents2); const int kFileLength3 = strlen(kFileContents3); - generator.AddFile(kFileName1, kFileLength1); + EXPECT_TRUE(generator.AddFile(kFileName1, kFileLength1)); MemoryReadStream file1_stream(reinterpret_cast<const uint8*>(kFileContents1), kFileLength1); generator.AddFileBytes(&file1_stream, kFileLength1); - generator.AddFile(kFileName2, kFileLength2); + EXPECT_TRUE(generator.AddFile(kFileName2, kFileLength2)); MemoryReadStream file2_stream(reinterpret_cast<const uint8*>(kFileContents2), kFileLength2); generator.AddFileBytes(&file2_stream, kFileLength2); - generator.AddFile(kFileName3, kFileLength3); + EXPECT_TRUE(generator.AddFile(kFileName3, kFileLength3)); MemoryReadStream file3_stream(reinterpret_cast<const uint8*>(kFileContents3), kFileLength3); generator.AddFileBytes(&file3_stream, kFileLength3); + EXPECT_TRUE(generator.AddFile(kFileName4, kFileLength3)); + MemoryReadStream file4_stream(reinterpret_cast<const uint8*>(kFileContents3), + kFileLength3); + generator.AddFileBytes(&file4_stream, kFileLength3); generator.Finalize(); |