forked from chipsalliance/Surelog
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue chipsalliance#3221, chipsalliance#3219: Follow up and fixing wa…
…rnings * Fixed build warnings and also updated the workflow to match local settings so the warnings should now be reported on CI as well. * Add unit tests for PathId * Some documentation & decorative changes
- Loading branch information
1 parent
943b469
commit 7aa2d22
Showing
10 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
Copyright 2021 Alain Dargelas | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#include <Surelog/Common/FileSystem.h> | ||
#include <Surelog/Common/PathId.h> | ||
#include <Surelog/SourceCompile/SymbolTable.h> | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <filesystem> | ||
#include <memory> | ||
|
||
namespace SURELOG { | ||
|
||
using ::testing::ElementsAre; | ||
namespace fs = std::filesystem; | ||
|
||
namespace { | ||
class TestFileSystem : public FileSystem { | ||
public: | ||
TestFileSystem() : FileSystem(std::filesystem::current_path()) {} | ||
}; | ||
|
||
TEST(PathId, constructors) { | ||
std::unique_ptr<SymbolTable> symbolTableA(new SymbolTable); | ||
std::unique_ptr<SymbolTable> symbolTableB(new SymbolTable); | ||
std::unique_ptr<FileSystem> fileSystem(new TestFileSystem); | ||
|
||
PathId pathId1a = fileSystem->toPathId(fs::path(testing::TempDir()) / "path1", | ||
symbolTableA.get()); | ||
PathId pathId2a = fileSystem->toPathId(fs::path(testing::TempDir()) / "path2", | ||
symbolTableA.get()); | ||
|
||
PathId pathId1b = fileSystem->toPathId(fs::path(testing::TempDir()) / "path1", | ||
symbolTableB.get()); | ||
PathId pathId2b = fileSystem->toPathId(fs::path(testing::TempDir()) / "path2", | ||
symbolTableB.get()); | ||
|
||
EXPECT_EQ(pathId1a.getSymbolTable(), pathId2a.getSymbolTable()); | ||
EXPECT_EQ(pathId1b.getSymbolTable(), pathId2b.getSymbolTable()); | ||
EXPECT_NE(pathId1a.getSymbolTable(), pathId1b.getSymbolTable()); | ||
|
||
PathId pathId3a(pathId1a); | ||
EXPECT_EQ(pathId1a, pathId3a); | ||
EXPECT_EQ(pathId1a.getSymbolTable(), pathId3a.getSymbolTable()); | ||
} | ||
|
||
TEST(PathId, assignment_operator) { | ||
std::unique_ptr<SymbolTable> symbolTableA(new SymbolTable); | ||
std::unique_ptr<FileSystem> fileSystem(new TestFileSystem); | ||
|
||
PathId pathId1 = fileSystem->toPathId(fs::path(testing::TempDir()) / "path1", | ||
symbolTableA.get()); | ||
|
||
PathId pathId2 = pathId1; | ||
EXPECT_EQ(pathId1, pathId2); | ||
EXPECT_EQ(pathId1.getSymbolTable(), pathId2.getSymbolTable()); | ||
} | ||
|
||
TEST(PathId, comparison_operators) { | ||
std::unique_ptr<SymbolTable> symbolTableA(new SymbolTable); | ||
std::unique_ptr<FileSystem> fileSystem(new TestFileSystem); | ||
|
||
PathId pathId1 = fileSystem->toPathId(fs::path(testing::TempDir()) / "path1", | ||
symbolTableA.get()); | ||
PathId pathId2 = fileSystem->toPathId(fs::path(testing::TempDir()) / "path2", | ||
symbolTableA.get()); | ||
|
||
PathId pathId4, pathId5; | ||
EXPECT_EQ(pathId4, pathId4); // Both empty self | ||
EXPECT_EQ(pathId1, pathId1); // Against non-empty self | ||
EXPECT_EQ(pathId4, pathId5); // Two distinct empty | ||
EXPECT_NE(pathId1, pathId4); // Empty against not | ||
EXPECT_NE(pathId1, pathId2); // Two distinct non-empty | ||
|
||
std::unique_ptr<SymbolTable> symbolTableB(new SymbolTable); | ||
PathId pathId6 = fileSystem->toPathId(fs::path(testing::TempDir()) / "path1", | ||
symbolTableB.get()); | ||
EXPECT_NE(pathId1.getSymbolTable(), pathId6.getSymbolTable()); | ||
EXPECT_EQ(pathId1, pathId6); // Same stored in distinct SymbolTables | ||
} | ||
|
||
} // namespace | ||
} // namespace SURELOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters