| 382 | } |
| 383 | |
| 384 | TEST(CheckAttrExists, All) { |
| 385 | NodeDef node; |
| 386 | node.set_name("node"); |
| 387 | (*node.mutable_attr())["apple"].set_i(7); |
| 388 | (*node.mutable_attr())["pear"].set_b(true); |
| 389 | |
| 390 | TF_EXPECT_OK(CheckAttrExists(node, "apple")); |
| 391 | TF_EXPECT_OK(CheckAttrExists(node, "pear")); |
| 392 | |
| 393 | TF_EXPECT_OK(CheckAttrsExist(node, {})); |
| 394 | TF_EXPECT_OK(CheckAttrsExist(node, {"apple"})); |
| 395 | TF_EXPECT_OK(CheckAttrsExist(node, {"pear"})); |
| 396 | TF_EXPECT_OK(CheckAttrsExist(node, {"apple", "pear"})); |
| 397 | TF_EXPECT_OK(CheckAttrsExist(node, {"pear", "apple"})); |
| 398 | |
| 399 | Status status = CheckAttrExists(node, "banana"); |
| 400 | EXPECT_FALSE(status.ok()); |
| 401 | EXPECT_EQ(status.ToString(), |
| 402 | "Invalid argument: Node 'node' lacks 'banana' attr: name: \"node\" " |
| 403 | "attr { key: \"apple\" value { i: 7 } } attr { key: \"pear\" value " |
| 404 | "{ b: true } }"); |
| 405 | EXPECT_FALSE(CheckAttrsExist(node, {""}).ok()); |
| 406 | EXPECT_FALSE(CheckAttrsExist(node, {"pear", "cherry"}).ok()); |
| 407 | EXPECT_FALSE(CheckAttrsExist(node, {"banana", "apple"}).ok()); |
| 408 | } |
| 409 | |
| 410 | TEST_F(UtilsTest, DeleteNodes) { |
| 411 | // TODO(rmlarsen): write forgotten test. |
nothing calls this directly
no test coverage detected