| 11 | namespace custom { |
| 12 | |
| 13 | TEST(TestOpManager, TestOpManager) { |
| 14 | CustomOpManager* com = CustomOpManager::inst(); |
| 15 | std::vector<std::string> builtin_op_names = com->op_name_list(); |
| 16 | size_t builtin_op_num = builtin_op_names.size(); |
| 17 | |
| 18 | com->insert("Op1", CUSTOM_OP_VERSION); |
| 19 | com->insert("Op2", CUSTOM_OP_VERSION); |
| 20 | |
| 21 | std::vector<std::string> op_names = com->op_name_list(); |
| 22 | std::vector<RunTimeId> op_ids = com->op_id_list(); |
| 23 | |
| 24 | ASSERT_TRUE(op_names.size() == builtin_op_num + 2); |
| 25 | ASSERT_TRUE(op_ids.size() == builtin_op_num + 2); |
| 26 | |
| 27 | #if MANAGER_TEST_LOG |
| 28 | for (std::string& name : op_names) { |
| 29 | std::cout << name << std::endl; |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | for (std::string& name : op_names) { |
| 34 | std::shared_ptr<const CustomOp> op = com->find(name); |
| 35 | ASSERT_TRUE(op != nullptr); |
| 36 | ASSERT_TRUE(op->op_type() == name); |
| 37 | RunTimeId id = com->to_id(name); |
| 38 | ASSERT_TRUE(com->find(id) == op); |
| 39 | } |
| 40 | |
| 41 | for (RunTimeId& id : op_ids) { |
| 42 | std::shared_ptr<const CustomOp> op = com->find(id); |
| 43 | ASSERT_TRUE(op != nullptr); |
| 44 | ASSERT_TRUE(op->runtime_id() == id); |
| 45 | std::string name = com->to_name(id); |
| 46 | ASSERT_TRUE(com->find(name) == op); |
| 47 | } |
| 48 | |
| 49 | ASSERT_FALSE(com->erase("Op0")); |
| 50 | #if MANAGER_TEST_LOG |
| 51 | for (auto& name : com->op_name_list()) { |
| 52 | std::cout << name << std::endl; |
| 53 | } |
| 54 | #endif |
| 55 | ASSERT_TRUE(com->erase("Op1")); |
| 56 | ASSERT_TRUE(com->op_id_list().size() == builtin_op_num + 1); |
| 57 | ASSERT_TRUE(com->op_name_list().size() == builtin_op_num + 1); |
| 58 | ASSERT_TRUE(com->erase("Op2")); |
| 59 | } |
| 60 | |
| 61 | TEST(TestOpManager, TestOpReg) { |
| 62 | CUSTOM_OP_REG(Op1) |
nothing calls this directly
no test coverage detected