Extend generator filtering to support element ranges

未关闭
#3,071 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

  • #3189 来自 @annacastroops —— 已关闭,未合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
cpp
领域
cli, testing-qa

调研方向

首先定位最近添加的生成器过滤实现,以及已经使用逗号表示 OR 的测试规范。根据示例和设计问题定义可接受的范围语法和验证行为,然后为组合、顺序、重复项、重叠以及格式错误或负数范围添加覆盖;完成的标准是有效过滤器选择预期的生成器元素,而无效过滤器被拒绝。

由索引模型根据 Issue 内容生成。

描述

Feature Request

Note that all the ideas here are fully backwards compatible, so the
extension can be implemented without a breaking change

The recently-added generator filtering only allows filtering to a singular
element. This can be extended to support multiple elements and/or element
ranges.

For multiple separate elements, we can reuse the concept of commas as "OR"
from the test specs. This would then mean that -g 1,3,4 filters the
generator to indices 1, 3, and 4. For element ranges, we can use
the start-end format, so that -g 1-4 would filter the generator to
indices 1, 2, 3, and 4.

These two should also be combinable, so that -g 1,3,6-10 filters the
generator to indices 1, 3, 6, 7, ..., 10.

Examples

Accepted
  • -g 1,2 - Elements at indices 1 and 2.
  • -g 1-3 - Elements at indices 1, 2, and 3.
  • -g 1-1 - Single element range, only the element at index 1.
  • -g 1-3,4,5-10 - Elements at indices 1,...,10.
Rejected
  • -g 1-3,2-4 - The two element ranges are overlapping
  • -g 3,2,1 - Elements are in bad order, must be monotonically increasing
  • -g 3-1 - Range is decreasing, see above
  • -g 1,2,2,3 - 3rd element is duplicated
  • -g -2 - Negative number, should still be rejected
  • -g 1--2 - Syntactically invalid
  • -g 1-2-3 - Syntactically invalid

Design questions

  • Should the ranges be closed? Programming usually uses half-open ranges,
    but closed-ranges feel more intuitive for specifying the range on the
    command line.

  • Should we error out on bad-but-fixable filters? Erroring out is less
    confusing, but fixing can be more user friendly.

    • Duplicated indices can be deduplicated.
    • Unsorted indices can be sorted
    • Overlapping ranges could be merged
  • Should we support partially-specified ranges?

    • 3-* could mean "From 4th element to the end of the generator"
主要语言
C++
星标
21.6k
派生
3.4k
平均合并
3 天 12 小时
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

catchorg/Catch2 的其他 Issue

查看 catchorg/Catch2 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。