diff --git a/Common/cfcpp/cfitem.h b/Common/cfcpp/cfitem.h index c189b31304..3c1ea80976 100644 --- a/Common/cfcpp/cfitem.h +++ b/Common/cfcpp/cfitem.h @@ -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 +class CFItem : public std::enable_shared_from_this { public: int CompareTo(const CFItem& other) const; diff --git a/Common/cfcpp/test/tst_compondfile.h b/Common/cfcpp/test/tst_compondfile.h index 00eaf4f60f..a824b0d3cd 100644 --- a/Common/cfcpp/test/tst_compondfile.h +++ b/Common/cfcpp/test/tst_compondfile.h @@ -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 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 data = {0x28, 0xFF, 0x28, 0x1D, 0x4C, 0xFA, 0x00, 0x79, 0x40, 0x01}; + std::vector 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(); }