codegraph_python/relationships/
inheritance.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct InheritanceRelation {
6 pub child: String,
8
9 pub parent: String,
11
12 pub line: usize,
14}
15
16impl InheritanceRelation {
17 pub fn new(child: impl Into<String>, parent: impl Into<String>, line: usize) -> Self {
19 Self {
20 child: child.into(),
21 parent: parent.into(),
22 line,
23 }
24 }
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn test_inheritance_relation_new() {
33 let inheritance = InheritanceRelation::new("Dog", "Animal", 5);
34 assert_eq!(inheritance.child, "Dog");
35 assert_eq!(inheritance.parent, "Animal");
36 assert_eq!(inheritance.line, 5);
37 }
38}