-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from rocallahan/unit-tests
Adds unit testing framework to ABC
- Loading branch information
Showing
5 changed files
with
84 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
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 @@ | ||
add_subdirectory(gia) |
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,11 @@ | ||
add_executable(gia_test gia_test.cc) | ||
|
||
target_link_libraries(gia_test | ||
gtest | ||
gtest_main | ||
libabc | ||
) | ||
|
||
gtest_discover_tests(gia_test | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) |
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,54 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include "aig/gia/gia.h" | ||
|
||
ABC_NAMESPACE_IMPL_START | ||
|
||
TEST(GiaTest, CanAllocateGiaManager) { | ||
Gia_Man_t* aig_manager = Gia_ManStart(100); | ||
|
||
EXPECT_TRUE(aig_manager != nullptr); | ||
Gia_ManStop(aig_manager); | ||
} | ||
|
||
TEST(GiaTest, CanAddACi) { | ||
Gia_Man_t* aig_manager = Gia_ManStart(100); | ||
Gia_ManAppendCi(aig_manager); | ||
|
||
EXPECT_EQ(Gia_ManCiNum(aig_manager), 1); | ||
Gia_ManStop(aig_manager); | ||
} | ||
|
||
TEST(GiaTest, CanAddACo) { | ||
Gia_Man_t* aig_manager = Gia_ManStart(100); | ||
int input1 = Gia_ManAppendCi(aig_manager); | ||
Gia_ManAppendCo(aig_manager, input1); | ||
|
||
EXPECT_EQ(Gia_ManCiNum(aig_manager), 1); | ||
EXPECT_EQ(Gia_ManCoNum(aig_manager), 1); | ||
Gia_ManStop(aig_manager); | ||
} | ||
|
||
TEST(GiaTest, CanAddAnAndGate) { | ||
Gia_Man_t* aig_manager = Gia_ManStart(100); | ||
|
||
int input1 = Gia_ManAppendCi(aig_manager); | ||
int input2 = Gia_ManAppendCi(aig_manager); | ||
|
||
int and_output = Gia_ManAppendAnd(aig_manager, input1, input2); | ||
Gia_ManAppendCo(aig_manager, and_output); | ||
|
||
Vec_Wrd_t* stimulus = Vec_WrdAlloc(2); | ||
Vec_WrdPush(stimulus, /*A*/1); | ||
Vec_WrdPush(stimulus, /*B*/1); | ||
Vec_Wrd_t* output = Gia_ManSimPatSimOut(aig_manager, stimulus, /*fouts*/1); | ||
|
||
EXPECT_EQ(Gia_ManCiNum(aig_manager), 2); | ||
EXPECT_EQ(Gia_ManCoNum(aig_manager), 1); | ||
// A = 1, B = 1 -> A & B == 1 | ||
EXPECT_EQ(Vec_WrdGetEntry(output, 0), 1); | ||
Vec_WrdFree(output); | ||
Gia_ManStop(aig_manager); | ||
} | ||
|
||
ABC_NAMESPACE_IMPL_END |