As ctype only affects cpp implementation, these fields necessarily already work the same as any other string field. PiperOrigin-RevId: 646156640pull/17180/head
parent
8d8db9cea8
commit
6429885156
4 changed files with 59 additions and 4 deletions
@ -0,0 +1,35 @@ |
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2024 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::*; |
||||||
|
use unittest_proto3_rust_proto::TestAllTypes; |
||||||
|
|
||||||
|
#[test] |
||||||
|
fn test_stringpiece_repeated() { |
||||||
|
let mut msg = TestAllTypes::new(); |
||||||
|
assert_that!(msg.repeated_string_piece().len(), eq(0)); |
||||||
|
msg.repeated_string_piece_mut().push("hello".into()); |
||||||
|
assert_that!(msg.repeated_string_piece().len(), eq(1)); |
||||||
|
assert_that!(msg.repeated_string_piece().get(0), some(eq("hello"))); |
||||||
|
} |
||||||
|
|
||||||
|
#[test] |
||||||
|
fn test_cord() { |
||||||
|
let mut msg = TestAllTypes::new(); |
||||||
|
assert_that!(msg.optional_cord(), eq("")); |
||||||
|
msg.set_optional_cord("hello"); |
||||||
|
assert_that!(msg.optional_cord(), eq("hello")); |
||||||
|
} |
||||||
|
|
||||||
|
#[test] |
||||||
|
fn test_cord_repeated() { |
||||||
|
let mut msg = TestAllTypes::new(); |
||||||
|
assert_that!(msg.repeated_cord().len(), eq(0)); |
||||||
|
msg.repeated_cord_mut().push("hello".into()); |
||||||
|
assert_that!(msg.repeated_cord().len(), eq(1)); |
||||||
|
assert_that!(msg.repeated_cord().get(0), some(eq("hello"))); |
||||||
|
} |
Loading…
Reference in new issue