Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
xtofalex committed Mar 26, 2024
1 parent e0f06ea commit 0c289c0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/snl/snl/kernel/SNLBusTerm.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ class SNLBusTerm final: public SNLTerm {
SNLName getName() const override { return name_; }
bool isAnonymous() const override { return name_.empty(); }
void setName(const SNLName& name) override;
const char* getTypeName() const override;

SNLTerm::Direction getDirection() const override { return direction_; }
void setDirection(const SNLTerm::Direction& direction) { direction_ = direction; }

const char* getTypeName() const override;
std::string getString() const override;
std::string getDescription() const override;
void debugDump(size_t indent, bool recursive=true, std::ostream& stream=std::cerr) const override;
Expand Down
1 change: 1 addition & 0 deletions src/snl/snl/kernel/SNLNetComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SNLNetComponent: public SNLDesignObject {
};
Direction(const DirectionEnum& dirEnum);
Direction(const Direction& direction) = default;
Direction& operator=(const Direction& direction) = default;
operator const DirectionEnum&() const {return dirEnum_;}
std::string getString() const;
private:
Expand Down
2 changes: 2 additions & 0 deletions src/snl/snl/kernel/SNLScalarTerm.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class SNLScalarTerm final: public SNLBitTerm {
NajaCollection<SNLBitTerm*> getBits() const override;

SNLTerm::Direction getDirection() const override { return direction_; }
void setDirection(const SNLTerm::Direction& direction) { direction_ = direction; }

const char* getTypeName() const override;
std::string getString() const override;
std::string getDescription() const override;
Expand Down
25 changes: 24 additions & 1 deletion test/snl/snl/kernel/SNLInstanceSetModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ TEST_F(SNLInstanceSetModelTest, testAnonymousContradictionError) {
EXPECT_THROW(ins0_->setModel(newModel), SNLException);
}

TEST_F(SNLInstanceSetModelTest, testDifferentNetNameError) {
TEST_F(SNLInstanceSetModelTest, testDifferentTermNameError) {
//clone model
auto newModel = model_->clone();
ASSERT_NE(newModel, nullptr);
Expand All @@ -108,6 +108,29 @@ TEST_F(SNLInstanceSetModelTest, testDifferentNetNameError) {
EXPECT_THROW(ins0_->setModel(newModel), SNLException);
}

TEST_F(SNLInstanceSetModelTest, testDifferentTermIDError) {
//clone model
auto newModel = model_->clone();
ASSERT_NE(newModel, nullptr);
ASSERT_EQ(5, newModel->getTerms().size());
auto term4 = newModel->getScalarTerm(SNLName("term4"));
ASSERT_NE(nullptr, term4);
term4->destroy();
SNLScalarTerm::create(newModel, SNLID::DesignObjectID(9), SNLTerm::Direction::InOut, SNLName("term4"));
EXPECT_THROW(ins0_->setModel(newModel), SNLException);
}

TEST_F(SNLInstanceSetModelTest, testDifferentTermDirectionError) {
//clone model
auto newModel = model_->clone();
ASSERT_NE(newModel, nullptr);
ASSERT_EQ(5, newModel->getTerms().size());
auto term3 = newModel->getBusTerm(SNLName("term3"));
ASSERT_NE(nullptr, term3);
term3->setDirection(SNLTerm::Direction::Input);
EXPECT_THROW(ins0_->setModel(newModel), SNLException);
}

TEST_F(SNLInstanceSetModelTest, testDifferentSizeBusError) {
//clone model
auto newModel = model_->clone();
Expand Down

0 comments on commit 0c289c0

Please sign in to comment.