-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a trivial 2023 edition test case for Rust.
PiperOrigin-RevId: 588874094
- Loading branch information
1 parent
361faa6
commit 43f92cb
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
edition = "2023"; | ||
|
||
package test; | ||
|
||
message EditionsMessage { | ||
int32 plain_field = 1; | ||
int32 implicit_presence_field = 2 [features.field_presence = IMPLICIT]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Protocol Buffers - Google's data interchange format | ||
// Copyright 2023 Google LLC. All rights reserved. | ||
// | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file or at | ||
// https://developers.google.com/open-source/licenses/bsd | ||
|
||
use googletest::prelude::*; | ||
|
||
// Tests that an proto file that declares edition="2023" works. Note that this | ||
// is _not_ a test for Rust Edition 2023 (which doesn't exist) but instead | ||
// Protobuf Edition 2023 (which exists). | ||
|
||
#[test] | ||
fn check_edition2023_works() { | ||
let mut msg = edition2023_proto::test::EditionsMessage::new(); | ||
|
||
// plain_field supports presence. | ||
assert_that!(msg.plain_field_mut().or_default().get(), eq(0)); | ||
|
||
// implicit presence fields' _mut() skips FieldEntry. | ||
assert_that!(msg.implicit_presence_field_mut().get(), eq(0)); | ||
} |