diff options
author | Casper <casperneo@uchicago.edu> | 2021-02-12 09:41:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 09:41:10 -0500 |
commit | 86401e078d0746d2381735415f8c2dfe849f3f52 (patch) | |
tree | 048e8698dec64bc5445b7f2680f67b7c9773d522 /tests/rust_usage_test | |
parent | 6af37e672947bb29b53650119585b38766f74d96 (diff) | |
download | flatbuffers-86401e078d0746d2381735415f8c2dfe849f3f52.tar.gz flatbuffers-86401e078d0746d2381735415f8c2dfe849f3f52.tar.bz2 flatbuffers-86401e078d0746d2381735415f8c2dfe849f3f52.zip |
Default strings and vectors: Parser + Rust support (#6421)
* Fix tests.cpp
* Parser support for vector/string defaults
* tests and default empty vectors
* addressed comments
* Default strings and vectors for Rust
* Tested Rust more_defaults
* git-clang-format
* add more_defaults_test
* fixed vector default
* removed commented out code
* more unreachable
Co-authored-by: Casper Neo <cneo@google.com>
Diffstat (limited to 'tests/rust_usage_test')
-rw-r--r-- | tests/rust_usage_test/tests/integration_test.rs | 1 | ||||
-rw-r--r-- | tests/rust_usage_test/tests/more_defaults_test.rs | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/rust_usage_test/tests/integration_test.rs b/tests/rust_usage_test/tests/integration_test.rs index 9bbbe88a..ccc69d2b 100644 --- a/tests/rust_usage_test/tests/integration_test.rs +++ b/tests/rust_usage_test/tests/integration_test.rs @@ -30,6 +30,7 @@ extern crate quickcheck_derive; mod flexbuffers_tests; mod optional_scalars_test; +mod more_defaults_test; #[allow(dead_code, unused_imports)] #[path = "../../include_test/include_test1_generated.rs"] diff --git a/tests/rust_usage_test/tests/more_defaults_test.rs b/tests/rust_usage_test/tests/more_defaults_test.rs new file mode 100644 index 00000000..5127bb96 --- /dev/null +++ b/tests/rust_usage_test/tests/more_defaults_test.rs @@ -0,0 +1,26 @@ +#[allow(dead_code, unused_imports)] +#[path = "../../more_defaults_generated.rs"] +mod more_defaults_generated; +use self::more_defaults_generated::*; + +#[test] +fn object_defaults() { + assert_eq!( + MoreDefaultsT::default(), + MoreDefaultsT { + ints: Vec::new(), + floats: Vec::new(), + empty_string: "".to_string(), + some_string: "some".to_string(), + }, + ) +} + +#[test] +fn nonpresent_values() { + let m = flatbuffers::root::<MoreDefaults>(&[0; 4]).unwrap(); + assert_eq!(m.ints().len(), 0); + assert_eq!(m.floats().len(), 0); + assert_eq!(m.empty_string(), ""); + assert_eq!(m.some_string(), "some"); +} |