1
1
use std:: { cell:: RefCell , pin:: Pin } ;
2
2
3
- use crate :: { inner, model:: Model , pin_ptr, sbmlcxx, upcast_annotation} ;
3
+ use crate :: { inner, model:: Model , pin_ptr, sbase , sbmlcxx, upcast_annotation} ;
4
4
5
5
/// A safe wrapper around the libSBML ListOfReactions class.
6
6
///
@@ -24,8 +24,56 @@ impl<'a> ListOfReactions<'a> {
24
24
25
25
// Derive the inner type from the ListOfReactions type
26
26
inner ! ( sbmlcxx:: ListOfReactions , ListOfReactions <' a>) ;
27
+ sbase ! ( ListOfReactions <' a>, sbmlcxx:: ListOfReactions ) ;
27
28
upcast_annotation ! (
28
29
ListOfReactions <' a>,
29
30
sbmlcxx:: ListOfReactions ,
30
31
sbmlcxx:: SBase
31
32
) ;
33
+
34
+ #[ cfg( test) ]
35
+ mod tests {
36
+ use serde:: { Deserialize , Serialize } ;
37
+
38
+ use crate :: sbmldoc:: SBMLDocument ;
39
+
40
+ #[ test]
41
+ fn test_list_of_reactions_annotation_serde ( ) {
42
+ let doc = SBMLDocument :: default ( ) ;
43
+ let model = doc. create_model ( "test" ) ;
44
+
45
+ #[ derive( Serialize , Deserialize ) ]
46
+ struct TestAnnotation {
47
+ test : String ,
48
+ }
49
+
50
+ let annotation = TestAnnotation {
51
+ test : "Test" . to_string ( ) ,
52
+ } ;
53
+
54
+ model. set_reactions_annotation_serde ( & annotation) . unwrap ( ) ;
55
+
56
+ let annotation: TestAnnotation = model. get_reactions_annotation_serde ( ) . unwrap ( ) ;
57
+ assert_eq ! ( annotation. test, "Test" ) ;
58
+ }
59
+
60
+ #[ test]
61
+ fn test_list_of_reactions_annotation ( ) {
62
+ let doc = SBMLDocument :: default ( ) ;
63
+ let model = doc. create_model ( "test" ) ;
64
+
65
+ let annotation = "<test>Test</test>" ;
66
+ model
67
+ . set_reactions_annotation ( annotation)
68
+ . expect ( "Failed to set annotation" ) ;
69
+
70
+ let annotation = model. get_reactions_annotation ( ) ;
71
+ assert_eq ! (
72
+ annotation
73
+ . replace( "\n " , "" )
74
+ . replace( "\r " , "" )
75
+ . replace( " " , "" ) ,
76
+ "<annotation><test>Test</test></annotation>"
77
+ ) ;
78
+ }
79
+ }
0 commit comments