fn test_names()

in uniffi_bindgen/src/interface/mod.rs [1438:1482]


    fn test_names() {
        let mut ci = ComponentInterface::default();

        let ob = Object {
            name: "ob".to_string(),
            module_path: "mp".to_string(),
            imp: ObjectImpl::Struct,
            remote: false,
            constructors: Default::default(),
            methods: Default::default(),
            uniffi_traits: Default::default(),
            ffi_func_clone: Default::default(),
            trait_impls: Default::default(),
            ffi_func_free: Default::default(),
            ffi_init_callback: Default::default(),
            docstring: Default::default(),
        };
        ci.add_object_definition(ob).unwrap();
        assert!(ci.get_object_definition("ob").is_some());
        assert_eq!(
            ci.types.get_type_definition("ob"),
            Some(Type::Object {
                module_path: "mp".to_string(),
                name: "ob".to_string(),
                imp: ObjectImpl::Struct
            })
        );

        let cb = CallbackInterface {
            name: "cb".to_string(),
            module_path: "mp".to_string(),
            methods: vec![],
            ffi_init_callback: FfiFunction::default(),
            docstring: None,
        };
        ci.add_callback_interface_definition(cb).unwrap();
        assert_eq!(
            ci.types.get_type_definition("cb"),
            Some(Type::CallbackInterface {
                module_path: "mp".to_string(),
                name: "cb".to_string()
            })
        );
        assert!(ci.get_callback_interface_definition("cb").is_some());
    }