MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / regions_fixture

Function regions_fixture

tests/test_ui.c:875–916  ·  view source on GitHub ↗

Two call communities in two folders, one cross call. The region level must * find both, name them by their dominant folder, aggregate the cross edge, * and lay them out deterministically. */

Source from the content-addressed store, hash-verified

873 * find both, name them by their dominant folder, aggregate the cross edge,
874 * and lay them out deterministically. */
875static cbm_store_t *regions_fixture(void) {
876 cbm_store_t *store = cbm_store_open_memory();
877 if (!store)
878 return NULL;
879 cbm_store_upsert_project(store, "regions-test", "/tmp/regions-test");
880 static const struct {
881 const char *name;
882 const char *file;
883 } defs[] = {
884 {"alpha_one", "src/alpha/a1.c"}, {"alpha_two", "src/alpha/a1.c"},
885 {"alpha_three", "src/alpha/a2.c"}, {"beta_one", "src/beta/b1.c"},
886 {"beta_two", "src/beta/b1.c"}, {"beta_three", "src/beta/b2.c"},
887 };
888 int64_t ids[6];
889 for (int i = 0; i < 6; i++) {
890 cbm_node_t node;
891 memset(&node, 0, sizeof(node));
892 node.project = "regions-test";
893 node.label = "Function";
894 node.name = defs[i].name;
895 char qn[128];
896 snprintf(qn, sizeof(qn), "regions-test::%s", defs[i].name);
897 node.qualified_name = qn;
898 node.file_path = defs[i].file;
899 node.start_line = 1;
900 node.end_line = 5;
901 ids[i] = cbm_store_upsert_node(store, &node);
902 }
903 /* Dense intra-community calls, one cross call alpha_one → beta_one. */
904 static const int pairs[][2] = {{0, 1}, {1, 2}, {2, 0}, {0, 2}, {3, 4},
905 {4, 5}, {5, 3}, {3, 5}, {0, 3}};
906 for (size_t e = 0; e < sizeof(pairs) / sizeof(pairs[0]); e++) {
907 cbm_edge_t edge;
908 memset(&edge, 0, sizeof(edge));
909 edge.project = "regions-test";
910 edge.source_id = ids[pairs[e][0]];
911 edge.target_id = ids[pairs[e][1]];
912 edge.type = "CALLS";
913 cbm_store_insert_edge(store, &edge);
914 }
915 return store;
916}
917
918TEST(layout_regions_two_communities) {
919 cbm_layout_regions_cache_clear();

Callers 2

test_ui.cFile · 0.85
atlas_fixtureFunction · 0.85

Calls 4

cbm_store_open_memoryFunction · 0.85
cbm_store_upsert_projectFunction · 0.85
cbm_store_upsert_nodeFunction · 0.85
cbm_store_insert_edgeFunction · 0.85

Tested by

no test coverage detected