Skip to content

Commit

Permalink
change Occurrence getString
Browse files Browse the repository at this point in the history
  • Loading branch information
xtofalex committed Nov 5, 2024
1 parent 8efb88a commit 85de584
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/snl/snl/kernel/SNLOccurrence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ SNLPath SNLOccurrence::getPath() const {
return SNLPath();
}

std::string SNLOccurrence::getString() const {
std::string SNLOccurrence::getString(const char separator) const {
std::ostringstream oss;
oss << getPath().getString(separator);
if (object_) {
oss << separator << object_->getString();
}
return oss.str();
}

std::string SNLOccurrence::getDescription() const {
std::ostringstream oss;
oss << "Occurrence: ";
if (object_) {
Expand Down
4 changes: 3 additions & 1 deletion src/snl/snl/kernel/SNLOccurrence.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class SNLOccurrence {
bool operator<=(const SNLOccurrence& occurrence) const;
bool operator>(const SNLOccurrence& occurrence) const;
bool operator>=(const SNLOccurrence& occurrence) const;
std::string getString() const;

std::string getString(const char separator='/') const;
std::string getDescription() const;

#if 0
// Following methods can be removed if SNLOccurrence inherits
Expand Down
4 changes: 2 additions & 2 deletions test/snl/snl/kernel/SNLOccurrenceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SNLOccurrenceTest: public ::testing::Test {
SNLInstance* h0Instance_ {nullptr};
};

TEST_F(SNLOccurrenceTest, testhEmptyOccurrences0) {
TEST_F(SNLOccurrenceTest, testEmptyOccurrences0) {
ASSERT_NE(SNLUniverse::get(), nullptr);
auto emptyPath = SNLPath();
auto emptyNetOccurrence = SNLBitNetOccurrence();
Expand All @@ -89,7 +89,7 @@ TEST_F(SNLOccurrenceTest, testhEmptyOccurrences0) {
EXPECT_FALSE(emptyInstTermOccurrence < emptyNetOccurrence);
}

TEST_F(SNLOccurrenceTest, testhEmptyOccurrences1) {
TEST_F(SNLOccurrenceTest, testEmptyOccurrences1) {
ASSERT_NE(SNLUniverse::get(), nullptr);
auto emptyPath = SNLPath();
auto emptyNetOccurrence = SNLBitNetOccurrence(emptyPath, nullptr);
Expand Down

0 comments on commit 85de584

Please sign in to comment.