summaryrefslogtreecommitdiff
path: root/test/contrained.c
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2025-03-23 15:36:22 +0100
committerJesper Jensen <jesper@jnsn.dev>2025-03-23 15:36:22 +0100
commit085906735bbadeb8e6cd47fc11610fe104080032 (patch)
tree3ae60b6feb86e24efa3bdb0fcad28ccbd9564725 /test/contrained.c
parent50da512936a9af6ad9aa808531af8f316a381dd4 (diff)
Add some cost calculation
Diffstat (limited to 'test/contrained.c')
-rw-r--r--test/contrained.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/contrained.c b/test/contrained.c
index 1af01a8..37fae1d 100644
--- a/test/contrained.c
+++ b/test/contrained.c
@@ -277,5 +277,60 @@ int main(int argc, char **argv) {
);
}
+ {
+ struct Tree a = {
+ .adj = {
+ .data = (nid[]){2, 0},
+ .stride = 1,
+ },
+ .len = 2,
+ };
+
+ struct Tree b = {
+ .adj = {
+ .data = (nid[]){2, 3, 0},
+ .stride = 1,
+ },
+ .len = 3,
+ };
+
+ DECL_MAT_DATA(cost, uint32_t, 3, 4,
+ 0, 2, 2,
+ 2, 0, 2,
+ 2, 2, 2,
+ 2, 2, 0,
+ );
+ DECL_MAT(cost_n, uint32_t, 3, 4);
+ DECL_MAT(cost_f, uint32_t, 3, 4);
+ DECL_MAT(cost_s, uint32_t, 3, 2);
+
+ constrained_tree_distance(
+ a,
+ b,
+ cost,
+ cost_n,
+ cost_f,
+ cost_s
+ );
+
+ if(*imat_uint32_t(cost_n, 1, 1) != 2) {
+ log("Test Fail\n");
+ return 1;
+ }
+
+ DECL_MAT(alignment, uint32_t, 2, 2);
+ uint32_t adj_alignment[2] = {0, 0};
+ constrained_tree_alignment(
+ a,
+ b,
+ cost,
+ cost_n,
+ cost_f,
+ cost_s,
+ adj_alignment,
+ alignment
+ );
+ }
+
return 0;
}