From 994eb28d2c007ebc09795b300cedf0abe7130507 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Mon, 19 Dec 2022 18:05:30 -0800 Subject: [PATCH] Chain SetName calls where possible PiperOrigin-RevId: 496534328 --- mediapipe/framework/api2/builder_test.cc | 28 ++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/mediapipe/framework/api2/builder_test.cc b/mediapipe/framework/api2/builder_test.cc index d8522b3c8..b01c2b759 100644 --- a/mediapipe/framework/api2/builder_test.cc +++ b/mediapipe/framework/api2/builder_test.cc @@ -55,14 +55,12 @@ TEST(BuilderTest, BuildGraph) { TEST(BuilderTest, CopyableSource) { Graph graph; - Source a = graph.In("A").Cast(); - a.SetName("a"); - Source b = graph.In("B").Cast(); - b.SetName("b"); - SideSource side_a = graph.SideIn("SIDE_A").Cast(); - side_a.SetName("side_a"); - SideSource side_b = graph.SideIn("SIDE_B").Cast(); - side_b.SetName("side_b"); + Source a = graph.In("A").SetName("a").Cast(); + Source b = graph.In("B").SetName("b").Cast(); + SideSource side_a = + graph.SideIn("SIDE_A").SetName("side_a").Cast(); + SideSource side_b = + graph.SideIn("SIDE_B").SetName("side_b").Cast(); Destination out = graph.Out("OUT").Cast(); SideDestination side_out = graph.SideOut("SIDE_OUT").Cast(); @@ -89,10 +87,8 @@ TEST(BuilderTest, CopyableSource) { TEST(BuilderTest, BuildGraphWithFunctions) { Graph graph; - Source base = graph.In("IN").Cast(); - base.SetName("base"); - SideSource side = graph.SideIn("SIDE").Cast(); - side.SetName("side"); + Source base = graph.In("IN").SetName("base").Cast(); + SideSource side = graph.SideIn("SIDE").SetName("side").Cast(); auto foo_fn = [](Source base, SideSource side, Graph& graph) { auto& foo = graph.AddNode("Foo"); @@ -108,9 +104,8 @@ TEST(BuilderTest, BuildGraphWithFunctions) { return bar.Out("OUT")[0].Cast(); }; Source bar_out = bar_fn(foo_out, graph); - bar_out.SetName("out"); - bar_out >> graph.Out("OUT"); + bar_out.SetName("out") >> graph.Out("OUT"); CalculatorGraphConfig expected = mediapipe::ParseTextProtoOrDie(R"pb( @@ -429,8 +424,9 @@ TEST(BuilderTest, AnyTypeCanBeCast) { auto& node = graph.AddNode("AnyAndSameTypeCalculator"); any_input >> node[AnyAndSameTypeCalculator::kAnyTypeInput]; Source any_type_output = - node[AnyAndSameTypeCalculator::kAnyTypeOutput].Cast(); - any_type_output.SetName("any_type_output"); + node[AnyAndSameTypeCalculator::kAnyTypeOutput] + .SetName("any_type_output") + .Cast(); any_type_output >> graph.Out("GRAPH_ANY_OUTPUT").Cast();