Skip to content

Commit

Permalink
evol(tests): add clock tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesmadjeri committed Feb 19, 2024
1 parent 2d68da5 commit e50aaad
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ $(EXE): $(OBJ)
$(CXX) -o $(EXE) $^

$(TEST_EXE): $(TEST_OBJ)
$(CXX) -o $(TEST_EXE) $^ -lcriterion --coverage
$(CXX) -o $(TEST_EXE) $^ -lcriterion --coverage

test: $(TEST_EXE)
gcovr --exclude ./test
./$(TEST_EXE)

clean:
Expand Down
Binary file removed nanotester
Binary file not shown.
38 changes: 38 additions & 0 deletions test/Special/TestClock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <criterion/criterion.h>
#include <criterion/redirect.h>
#include "../../include/paths.hpp"
#include "../../src/Manager/Manager.hpp"

nts::Manager ClockManager;

void ClockSetup() {
ClockManager.initializeTruthTables(TRUTH_TABLE_PATH);
ClockManager.createComponent("clock", "clock1");
}

void ClockTeardown() {
ClockManager.clearComponents();
}

TestSuite(Clock, .init = ClockSetup, .fini = ClockTeardown);

Test(Clock, should_create_clock) {
nts::IComponent *component = ClockManager.getComponent("clock1");

cr_assert_eq(component->getLabel(), "clock1");
cr_assert_eq(component->getType(), nts::ComponentType::Input);
cr_assert_eq(component->getValue(1), nts::Tristate::Undefined);
}

Test(Clock, should_compute_behaviour) {
nts::IComponent *component = ClockManager.getComponent("clock1");

ClockManager.simulate(1);
cr_assert_eq(component->getValue(1), nts::Tristate::True);

ClockManager.simulate(2);
cr_assert_eq(component->getValue(1), nts::Tristate::False);

ClockManager.simulate(3);
cr_assert_eq(component->getValue(1), nts::Tristate::True);
}
Empty file added test/Special/TestConstant.cpp
Empty file.

0 comments on commit e50aaad

Please sign in to comment.