-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/cgnode-tests' into 'devel'
[Graph] Adds CgNode unit tests See merge request tuda-sc/projects/metacg!172
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* File: CGNodeTests.cpp | ||
* License: Part of the MetaCG project. Licensed under BSD 3 clause license. See LICENSE.txt file at | ||
* https://github.com/tudasc/metacg/LICENSE.txt | ||
*/ | ||
|
||
#include "CgNode.h" | ||
#include "gtest/gtest.h" | ||
|
||
TEST(CgNode, CreateNodeOnlyName) { | ||
auto n = new metacg::CgNode("foo"); | ||
EXPECT_NE(n, nullptr); | ||
EXPECT_EQ(n->getFunctionName(), "foo"); | ||
|
||
delete n; | ||
} | ||
|
||
TEST(CgNode, CreateNodeNameAndOrigin) { | ||
auto n = new metacg::CgNode("foo", "origin:21"); | ||
|
||
EXPECT_NE(n, nullptr); | ||
EXPECT_EQ(n->getFunctionName(), "foo"); | ||
EXPECT_EQ((n->getOrigin()), "origin:21"); | ||
|
||
delete n; | ||
} | ||
|
||
TEST(CgNode, NodesSame) { | ||
auto n = new metacg::CgNode("foo"); | ||
auto nn = new metacg::CgNode("foo"); | ||
|
||
EXPECT_NE(n, nullptr); | ||
EXPECT_NE(nn, nullptr); | ||
EXPECT_TRUE(n->isSameFunctionName(*nn)); | ||
EXPECT_TRUE(nn->isSameFunctionName(*n)); | ||
|
||
delete n; | ||
delete nn; | ||
} | ||
|
||
TEST(CgNode, NodesNotSameName) { | ||
auto n = new metacg::CgNode("foo"); | ||
auto nn = new metacg::CgNode("bar"); | ||
|
||
EXPECT_NE(n, nullptr); | ||
EXPECT_NE(nn, nullptr); | ||
EXPECT_FALSE(n->isSameFunctionName(*nn)); | ||
EXPECT_FALSE(nn->isSameFunctionName(*n)); | ||
|
||
delete n; | ||
delete nn; | ||
} | ||
|
||
TEST(CgNode, NodesNameAndOriginSame) { | ||
auto n = new metacg::CgNode("foo", "origin:a"); | ||
auto nn = new metacg::CgNode("foo", "origin:a"); | ||
|
||
EXPECT_NE(n, nullptr); | ||
EXPECT_NE(nn, nullptr); | ||
EXPECT_TRUE(n->isSameFunctionName(*nn)); | ||
EXPECT_TRUE(nn->isSameFunctionName(*n)); | ||
|
||
delete n; | ||
delete nn; | ||
} | ||
|
||
TEST(CgNode, NodesNameAndOriginNotSame) { | ||
auto n = new metacg::CgNode("foo", "origin:a"); | ||
auto nn = new metacg::CgNode("foo", "origin:b"); | ||
|
||
EXPECT_NE(n, nullptr); | ||
EXPECT_NE(nn, nullptr); | ||
EXPECT_TRUE(n->isSameFunctionName(*nn)); | ||
EXPECT_TRUE(nn->isSameFunctionName(*n)); | ||
|
||
EXPECT_FALSE(n->isSameFunction(*nn)); | ||
EXPECT_FALSE(nn->isSameFunction(*n)); | ||
|
||
delete n; | ||
delete nn; | ||
} |
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