| 810 | |
| 811 | #[test] |
| 812 | fn test_extract_function() { |
| 813 | let mut parser = CppParser::new(); |
| 814 | let source = r#" |
| 815 | int add(int a, int b) { |
| 816 | return a + b; |
| 817 | } |
| 818 | "#; |
| 819 | let entities = parser.extract(source, "math.cpp"); |
| 820 | let add = entities.iter().find(|e| e.name == "add").unwrap(); |
| 821 | assert_eq!(add.kind, EntityKind::Function); |
| 822 | assert!( |
| 823 | add.signature |
| 824 | .as_ref() |
| 825 | .unwrap() |
| 826 | .contains("int add(int a, int b)"), |
| 827 | "Signature: {:?}", |
| 828 | add.signature |
| 829 | ); |
| 830 | } |
| 831 | |
| 832 | #[test] |
| 833 | fn test_extract_void_function() { |