blob: 798f932452a482038561c768bd6bbfe89a190f6d [file] [log] [blame]
Brian Silverman4e662aa2022-05-11 23:10:19 -07001// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use autocxx::prelude::*;
10include_cpp! {
11 #include "input.h"
12 safety!(unsafe_ffi)
13 generate!("DoMath")
14 generate!("Goat")
15}
16
17fn main() {
18 println!("Hello, world! - C++ math should say 12={}", ffi::DoMath(4));
19 let mut goat = ffi::Goat::new().within_box();
20 goat.as_mut().add_a_horn();
21 goat.as_mut().add_a_horn();
22 assert_eq!(
23 goat.describe().as_ref().unwrap().to_string_lossy(),
24 "This goat has 2 horns."
25 );
26}