forked from Kei18/lacam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test([instance]): add state machine simple test
- Loading branch information
1 parent
e4dd2a0
commit 02900e6
Showing
9 changed files
with
172 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
type single_port | ||
group 1 | ||
height 8 | ||
width 8 | ||
map | ||
TTTTTTTT | ||
T......T | ||
T....H.T | ||
TU.C.H.T | ||
T....H.T | ||
T......T | ||
T......T | ||
TTTTTTTT | ||
|
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
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 |
---|---|---|
@@ -1,15 +1,135 @@ | ||
#include <lacam.hpp> | ||
#include <calmapf.hpp> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
TEST(Instance, initialize) | ||
TEST(Instance, state_machine_test) | ||
{ | ||
const auto scen_filename = "./assets/random-32-32-10-random-1.scen"; | ||
const auto map_filename = "./assets/random-32-32-10.map"; | ||
const auto ins = Instance(scen_filename, map_filename, 3); | ||
|
||
ASSERT_EQ(size(ins.starts), 3); | ||
ASSERT_EQ(size(ins.goals), 3); | ||
ASSERT_EQ(ins.starts[0]->index, 203); | ||
ASSERT_EQ(ins.goals[0]->index, 583); | ||
Parser cache_state_machine_test_parser = Parser("./assets/test/test_instance.map", CacheType::LRU, 1); | ||
Instance instance(&cache_state_machine_test_parser); | ||
|
||
/* Graph | ||
TTTTTTTTT | ||
T.......T | ||
T.......T | ||
T..C.HH.T | ||
TU.C.HH.T | ||
T..C.HH.T | ||
T.......T | ||
T.......T | ||
TTTTTTTTT | ||
*/ | ||
|
||
// Initilization check | ||
ASSERT_EQ(1, instance.bit_status[0]); | ||
uint cache_access, cache_hit = 0; | ||
std::vector<Config> vertex_list; | ||
Config step; | ||
Vertex* goal = instance.graph.cargo_vertices[0][0];; | ||
|
||
// Generate goal queue | ||
instance.goals[0] = goal; | ||
instance.cargo_goals[0] = goal; | ||
instance.graph.goals_queue[0].clear(); | ||
instance.graph.goals_queue[0].push_back(instance.graph.cargo_vertices[0][1]); | ||
instance.graph.goals_queue[0].push_back(instance.graph.cargo_vertices[0][1]); | ||
instance.graph.goals_delay[0].clear(); | ||
instance.graph.goals_delay[0].push_back(0); | ||
instance.graph.goals_delay[0].push_back(0); | ||
instance.instance_console->info("Front goal {}", *(instance.graph.goals_queue[0].front())); | ||
|
||
|
||
// Status 1 -> Status 4 | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(4, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 4 -> Status 6 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(6, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 6 -> Status 0 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(1, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(0, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 0 -> Status 3 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(3, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 3 -> Status 1 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(1, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 1 -> Status 4 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(4, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 4 -> Status 6 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(6, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 6 -> Status 2 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(1, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(2, instance.bit_status[0]); | ||
|
||
goal = instance.goals[0]; | ||
|
||
// Status 2 -> Status 6 | ||
step.clear(); | ||
vertex_list.clear(); | ||
step.push_back(goal); | ||
vertex_list.push_back(step); | ||
|
||
ASSERT_EQ(0, instance.update_on_reaching_goals_with_cache(vertex_list, 100, cache_access, cache_hit)); | ||
ASSERT_EQ(6, instance.bit_status[0]); | ||
} |