Replace deprecate sapi:✌️:Proto ctor calls

PiperOrigin-RevId: 423760615
Change-Id: Id05341221fb6413d8f89d38470a9bc02f9d09b77
This commit is contained in:
Wiktor Garbacz 2022-01-24 02:09:20 -08:00 committed by Copybara-Service
parent 3c16be8347
commit e4436c87e8
2 changed files with 11 additions and 5 deletions

View File

@ -46,14 +46,17 @@ TEST(StringopTest, ProtobufStringDuplication) {
StringopApi api(sandbox);
stringop::StringDuplication proto;
proto.set_input("Hello");
sapi::v::Proto<stringop::StringDuplication> pp(proto);
auto pp = sapi::v::Proto<stringop::StringDuplication>::FromMessage(proto);
if (!pp.ok()) {
return pp.status();
}
{
SAPI_ASSIGN_OR_RETURN(int return_value,
api.pb_duplicate_string(pp.PtrBoth()));
api.pb_duplicate_string(pp->PtrBoth()));
TRANSACTION_FAIL_IF_NOT(return_value, "pb_duplicate_string() failed");
}
SAPI_ASSIGN_OR_RETURN(auto pb_result, pp.GetMessage());
SAPI_ASSIGN_OR_RETURN(auto pb_result, pp->GetMessage());
LOG(INFO) << "Result PB: " << pb_result.DebugString();
TRANSACTION_FAIL_IF_NOT(pb_result.output() == "HelloHello",
"Incorrect output");

View File

@ -134,8 +134,11 @@ absl::Status SumTransaction::Main() {
proto.set_a(10);
proto.set_b(20);
proto.set_c(30);
sapi::v::Proto<sumsapi::SumParamsProto> pp(proto);
SAPI_ASSIGN_OR_RETURN(v, f.sumproto(pp.PtrBefore()));
auto pp = sapi::v::Proto<sumsapi::SumParamsProto>::FromMessage(proto);
if (!pp.ok()) {
return pp.status();
}
SAPI_ASSIGN_OR_RETURN(v, f.sumproto(pp->PtrBefore()));
LOG(INFO) << "sumproto(proto {a = 10; b = 20; c = 30}) = " << v;
TRANSACTION_FAIL_IF_NOT(v == 60,
"sumproto(proto {a = 10; b = 20; c = 30}) != 60");