-
Notifications
You must be signed in to change notification settings - Fork 3
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 #5 from hassansalehe/critical-signature-uts
Critical signature uts
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <ostream> | ||
#include <string> | ||
|
||
#include "common/MemoryActions.h" | ||
|
||
class TestMemoryActionsFixture : public ::testing::Test { | ||
protected: | ||
INTEGER taskId = 123; | ||
ADDRESS addr = 0x033; | ||
VALUE value = 42; | ||
VALUE lineNo = 100; | ||
INTEGER funcId = 6; | ||
std::string funcName = "some_function"; | ||
bool isWrite = true; | ||
|
||
Action m_act; | ||
|
||
virtual void SetUp() { | ||
m_act = Action(taskId, addr, value, lineNo, funcId); | ||
} | ||
}; | ||
|
||
TEST_F(TestMemoryActionsFixture, CheckConstructorIsEmptyTrue) { | ||
MemoryActions m_actions; | ||
EXPECT_TRUE(m_actions.isEmpty); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, CheckConstructorWithActionArgument) { | ||
MemoryActions m_actions(m_act); | ||
EXPECT_FALSE(m_actions.isEmpty); | ||
EXPECT_EQ(taskId, m_actions.taskId); | ||
EXPECT_EQ(addr, m_actions.addr); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, CheckStoreActionFunction) { | ||
MemoryActions m_actions(m_act); | ||
EXPECT_FALSE(m_actions.isEmpty); | ||
EXPECT_EQ(taskId, m_actions.taskId); | ||
EXPECT_EQ(addr, m_actions.addr); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, CheckStoreActionFunctionWithParamsRead) { | ||
MemoryActions m_actions; | ||
EXPECT_TRUE(m_actions.isEmpty); | ||
|
||
// store | ||
uint ut = taskId; | ||
m_actions.storeAction(ut, addr, value, lineNo, funcId, false); | ||
|
||
EXPECT_EQ(taskId, m_actions.taskId); | ||
EXPECT_EQ(addr, m_actions.addr); | ||
EXPECT_FALSE(m_actions.isEmpty); | ||
|
||
EXPECT_EQ(taskId, m_actions.action.taskId); | ||
EXPECT_EQ(addr, m_actions.action.addr); | ||
EXPECT_EQ(funcId, m_actions.action.funcId); | ||
EXPECT_EQ(value, m_actions.action.value); | ||
EXPECT_EQ(lineNo, m_actions.action.lineNo); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, CheckHasWrite) { | ||
// Empty action has no write | ||
MemoryActions m_actions; | ||
EXPECT_FALSE(m_actions.hasWrite()); | ||
|
||
// Adding read action does not set acction to write | ||
m_actions.storeAction(m_act); | ||
EXPECT_FALSE(m_actions.hasWrite()); | ||
|
||
// Setting action to write | ||
m_actions.action.isWrite = true; | ||
EXPECT_TRUE(m_actions.hasWrite()); | ||
|
||
// adding a write action | ||
m_actions.action.isWrite = false; | ||
m_act.isWrite = true; | ||
m_actions.storeAction(m_act); | ||
EXPECT_TRUE(m_actions.hasWrite()); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, ChecPrintEmptyAction) { | ||
MemoryActions m_actions; | ||
std::ostringstream os; | ||
m_actions.printActions(os); | ||
EXPECT_EQ(0UL, os.str().size()); | ||
} | ||
|
||
TEST_F(TestMemoryActionsFixture, ChecPrintExistingAction) { | ||
m_act.isWrite = true; | ||
MemoryActions m_actions(m_act); | ||
std::ostringstream os; | ||
m_actions.printActions(os); | ||
|
||
std::string expected_message = "123 W 0x33 42 100 6\n"; | ||
EXPECT_EQ(expected_message, os.str()); | ||
} |