11use std:: { cell:: RefCell , pin:: Pin } ;
22
3- use crate :: { inner, model:: Model , pin_ptr, sbmlcxx, upcast_annotation} ;
3+ use crate :: { inner, model:: Model , pin_ptr, sbase , sbmlcxx, upcast_annotation} ;
44
55/// A safe wrapper around the libSBML ListOfReactions class.
66///
@@ -24,8 +24,56 @@ impl<'a> ListOfReactions<'a> {
2424
2525// Derive the inner type from the ListOfReactions type
2626inner ! ( sbmlcxx:: ListOfReactions , ListOfReactions <' a>) ;
27+ sbase ! ( ListOfReactions <' a>, sbmlcxx:: ListOfReactions ) ;
2728upcast_annotation ! (
2829 ListOfReactions <' a>,
2930 sbmlcxx:: ListOfReactions ,
3031 sbmlcxx:: SBase
3132) ;
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