Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix proto2 string field with bytes option and default value
Issue #395
- Loading branch information
1 parent
491f6bb
commit 9c9a3c8
Showing
4 changed files
with
56 additions
and
5 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
11 changes: 11 additions & 0 deletions
11
protobuf-test/src/v2/test_carllerche_bytes_default_value.rs
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,11 @@ | ||
use protobuf::*; | ||
|
||
use super::test_carllerche_bytes_default_value_pb::*; | ||
|
||
#[test] | ||
fn test_default_values() { | ||
assert_eq!("sss", TestCarllercheBytesDefaultValues::default_instance().get_s()); | ||
assert_eq!(b"bbb", TestCarllercheBytesDefaultValues::default_instance().get_b()); | ||
assert_eq!(&""[..], &**TestCarllercheBytesDefaultValues::new().mut_s()); | ||
assert_eq!(&b""[..], &**TestCarllercheBytesDefaultValues::new().mut_b()); | ||
} |
14 changes: 14 additions & 0 deletions
14
protobuf-test/src/v2/test_carllerche_bytes_default_value_pb.proto
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,14 @@ | ||
syntax = "proto2"; | ||
|
||
package test_carllerche_bytes_default_value; | ||
|
||
import "rustproto.proto"; | ||
|
||
option (rustproto.carllerche_bytes_for_bytes_all) = true; | ||
option (rustproto.carllerche_bytes_for_string_all) = true; | ||
option (rustproto.generate_accessors_all) = true; | ||
|
||
message TestCarllercheBytesDefaultValues { | ||
optional string s = 1 [default = "sss"]; | ||
optional bytes b = 2 [default = "bbb"]; | ||
} |