Add a collision-avoidance behavior to the Rust Proto codegen.
[google-protobuf.git] / rust / test / shared / bad_names_test.rs
bloba4b133b92fd040e476fbf04520fada1a80175297
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2023 Google LLC.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
8 use bad_names_proto::*;
9 use googletest::prelude::*;
11 #[test]
12 fn test_reserved_keyword_in_accessors() {
13     let msg = Self__mangled_because_ident_isnt_a_legal_raw_identifier::new();
14     let res = msg.self__mangled_because_ident_isnt_a_legal_raw_identifier().r#for();
15     assert_that!(res, eq(0));
18 #[test]
19 fn test_reserved_keyword_in_messages() {
20     let _ = r#enum::new();
21     let _ = Ref::new().r#const();
24 #[test]
25 fn test_collision_in_accessors() {
26     let mut m = AccessorsCollide::new();
27     m.set_x_mut_5(false);
28     assert_that!(m.x_mut_5(), eq(false));
29     assert_that!(m.has_x_mut_5(), eq(true));
30     assert_that!(m.has_x(), eq(false));
31     assert_that!(m.has_set_x_2(), eq(false));