Consider adding equality operators for various objects in the datamodel
还没有人认领这个 Issue。
评估
调研方向
从 include/up-cpp/uri/tools/Utils.h 的第 188-201 行开始,然后检查 URI 工具相等性测试以及 issue 中的 URI_UTILS testUResourceEquals 用例。验证 UResource 句柄的相等性是否一致地处理名称以及可选的实例字段或消息字段,并运行相关的 URI 工具测试,以确认失败用例和相关比较已得到解决。
由索引模型根据 Issue 内容生成。
描述
The logic in the '==' operators for URI (and its components do not seem to be correct).
This code is only comparing the instance portion of the URI if the left hand side includes the instance. However the logic should really be like this:
[[nodiscard]] [[maybe_unused]] auto static
operator==(const uprotocol::v1::UResource &s, const uprotocol::v1::UResource &o) -> bool {
// Resources are consider equal if:
// 1. Names are equal
// 2. Both Resources do not have an instance OR
// both Resource do have an instance and they are the same
// 3. Both Resources do not have a message OR
// both resources have a message and they are the same
return (s.name() == o.name()) && // Condition 1
// Condition 2
((!s.has_instance() && !o.has_instance()) ||
(s.has_instance() && o.has_instance() && s.instance() == o.instance())) && // Condition 2
// Condition 3
((!s.has_message() && !o.has_message()) ||
(s.has_message() && o.has_message() && s.message() == o.message())); // if exists must be same message
}
A simple test case (it fails right now) shows the problem with the code as is:
TEST(URI_UTILS, testUResourceEquals) {
using uprotocol::uri::BuildUResource;
using uprotocol::v1::UResource;
using uprotocol::uri::operator==;
// Resource 1 - No Instance
auto resource_1{BuildUResource().setName("rpc").build()};
// Resource 2 - With Instance
auto resource_2{BuildUResource().setName("rpc").setInstance("CreateTopic").build()};
EXPECT_FALSE(resource_1 == resource_2);
}
- 主要语言
- C++
- 星标
- 29
- 派生
- 32
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
eclipse-uprotocol/up-cpp 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 50/100
eclipse-uprotocol/up-cpp#327 ·
-
难度 4/5 3-5 天 新手友好度 30/100
eclipse-uprotocol/up-cpp#320 ·
-
难度 4/5 3-5 天 新手友好度 35/100
eclipse-uprotocol/up-cpp#319 ·
-
难度 5/5 一周以上 新手友好度 25/100
eclipse-uprotocol/up-cpp#303 ·
-
难度 3/5 1-2 天 新手友好度 35/100
eclipse-uprotocol/up-cpp#302 ·
查看 eclipse-uprotocol/up-cpp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
leanprover/lean4#15683 ·
维护者通常 1 天内回复
-
llvm.memcpy with destination align but no source align asserts "Missed Source alignment!"可能已有人在做 @pvelesko 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
KhronosGroup/SPIRV-LLVM-Translator#4093 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
SIMQ silently truncates multi-query batch search to the first query可能已有人在做 @LHT129 今天认领。 未关闭kind/bug module/index needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复