Download tests/src/App/Document.cpp from AbdulElahGwaith/FreeCAD: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/tests/src/App/Document.cpp
- Command line
-
hf download hf://AbdulElahGwaith/FreeCAD/tests/src/App/Document.cpp
-
curl -L -o Document.cpp https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/tests/src/App/Document.cpp
2 kB
| // SPDX-License-Identifier: LGPL-2.1-or-later | |
| using ::testing::Eq; | |
| using ::testing::Ne; | |
| // NOLINTBEGIN(readability-magic-numbers) | |
| class FakeWriter: public Base::Writer | |
| { | |
| void writeFiles() override | |
| {} | |
| std::ostream& Stream() override | |
| { | |
| return std::cout; | |
| } | |
| }; | |
| class DocumentTest: public ::testing::Test | |
| { | |
| protected: | |
| static void SetUpTestSuite() | |
| { | |
| tests::initApplication(); | |
| } | |
| void SetUp() override | |
| { | |
| _docName = App::GetApplication().getUniqueDocumentName("test"); | |
| _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser"); | |
| } | |
| void TearDown() override | |
| { | |
| App::GetApplication().closeDocument(_docName.c_str()); | |
| } | |
| App::Document* doc() | |
| { | |
| return _doc; | |
| } | |
| private: | |
| std::string _docName; | |
| App::Document* _doc {}; | |
| }; | |
| TEST_F(DocumentTest, addStringHasherIndicatesUnwrittenWhenNew) | |
| { | |
| // Arrange | |
| App::StringHasherRef hasher(new App::StringHasher); | |
| // Act | |
| auto addResult = doc()->addStringHasher(hasher); | |
| // Assert | |
| EXPECT_TRUE(addResult.first); | |
| EXPECT_THAT(addResult.second, Ne(-1)); | |
| } | |
| TEST_F(DocumentTest, addStringHasherIndicatesAlreadyWritten) | |
| { | |
| // Arrange | |
| App::StringHasherRef hasher(new App::StringHasher); | |
| doc()->addStringHasher(hasher); | |
| // Act | |
| auto addResult = doc()->addStringHasher(hasher); | |
| // Assert | |
| EXPECT_FALSE(addResult.first); | |
| } | |
| TEST_F(DocumentTest, getStringHasherGivesExpectedHasher) | |
| { | |
| // Arrange | |
| App::StringHasherRef hasher(new App::StringHasher); | |
| auto pair = doc()->addStringHasher(hasher); | |
| int index = pair.second; | |
| // Act | |
| auto foundHasher = doc()->getStringHasher(index); | |
| // Assert | |
| EXPECT_EQ(hasher, foundHasher); | |
| } | |
| // NOLINTEND(readability-magic-numbers) | |