Add test and fix std::shared_from_this: protected -> public

This commit is contained in:
Ivan Morozov
2022-09-21 13:17:42 +03:00
parent 62f1eb1967
commit 046e54f3f5
2 changed files with 19 additions and 4 deletions

View File

@ -15,7 +15,7 @@ struct DataTime
char data[8] = {0,0,0,0,0,0,0,0};
};
class CFItem : protected std::enable_shared_from_this<CFItem>
class CFItem : public std::enable_shared_from_this<CFItem>
{
public:
int CompareTo(const CFItem& other) const;

View File

@ -37,6 +37,7 @@ struct CompoundFileTest : testing::Test
<< left << dir->GetEntryName()
<< endl;
}
wcout << endl;
}
};
@ -143,13 +144,27 @@ TEST_F(CompoundFileTest, test_compoundfile_deleteStreamWithSave)
TEST_F(CompoundFileTest, test_compoundfile_deleteStorage)
{
std::vector<BYTE> data = {0x28, 0xFF, 0x28, 0x1D, 0x4C, 0xFA, 0x00, 0x79, 0x40, 0x01};
auto storage1 = cf.RootStorage()->AddStorage(L"sto1");
auto storage2 = storage1->AddStorage(L"sto2");
// storage1->AddStream(L"str1")->Write(data,0);
// storage2->AddStream(L"str2")->Write(data,0);
auto stream1 = storage2->AddStream(L"str1");
printDirs();
EXPECT_TRUE(cf.RootStorage()->GetStorage(L"sto1"));
cf.RootStorage()->Delete(L"sto1");
EXPECT_THROW(cf.RootStorage()->GetStorage(L"sto1"), CFItemNotFound);
printDirs();
}
TEST_F(CompoundFileTest, test_compoundfile_writeStream)
{
std::vector<BYTE> data = {0x28, 0xFF, 0x28, 0x1D, 0x4C, 0xFA, 0x00, 0x79, 0x40, 0x01};
std::vector<BYTE> read(data.size());
auto stream1 = cf.RootStorage()->AddStream(L"str1");
stream1->Write(data,0);
EXPECT_TRUE(cf.RootStorage()->GetStream(L"str1"));
stream1->Read(read, 0, data.size());
EXPECT_EQ(data.size(), read.size());
printDirs();
}