Skip to content

Commit 784514a

Browse files
committed
Added unit tests for graph indexable data in context graph.
Signed-off-by: Marvin Hansen <[email protected]>.
1 parent 50d547f commit 784514a

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
* Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4+
*/
5+
6+
use deep_causality::*;
7+
8+
fn get_context() -> BaseContext {
9+
let id = 1;
10+
let name = "base context";
11+
Context::with_capacity(id, name, 10)
12+
}
13+
14+
#[test]
15+
fn test_set_get_data_index_direct() {
16+
let mut ctx = get_context();
17+
18+
ctx.set_data_index(0, 0, true);
19+
let res = ctx.get_data_index(&0, true);
20+
assert!(res.is_some());
21+
let result = res.unwrap();
22+
assert_eq!(result, &0);
23+
24+
ctx.set_data_index(0, 42, false);
25+
26+
let res = ctx.get_data_index(&0, false);
27+
assert!(res.is_some());
28+
let result = res.unwrap();
29+
assert_eq!(result, &42);
30+
}
31+
32+
#[test]
33+
fn test_set_get_current_data_index() {
34+
let mut ctx = get_context();
35+
36+
ctx.set_current_data_index(42);
37+
38+
let res = ctx.get_current_data_index();
39+
assert!(res.is_some());
40+
let result = res.unwrap();
41+
assert_eq!(result, &42);
42+
}
43+
44+
#[test]
45+
fn test_set_get_previous_data_index() {
46+
let mut ctx = get_context();
47+
48+
ctx.set_previous_data_index(23);
49+
let res = ctx.get_previous_data_index();
50+
assert!(res.is_some());
51+
let result = res.unwrap();
52+
assert_eq!(result, &23);
53+
}

deep_causality/tests/types/context_types/context_graph/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ mod extendable_context_tests;
1313
#[cfg(test)]
1414
mod extendable_contextuable_graph_tests;
1515
#[cfg(test)]
16+
mod graph_indexable_data_tests;
17+
#[cfg(test)]
1618
mod graph_indexable_time_tests;
1719
#[cfg(test)]
1820
mod graph_node_tests;

0 commit comments

Comments
 (0)