Implement `constexpr` generators or add the possibility for combining signature-based parametrised tests

Abierto
#3,014 0 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
28/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
testing

Línea de trabajo

Empieza leyendo docs/generators.md y docs/test-cases-and-sections.md, especialmente las secciones sobre tests basados en generator, parametrizados por tipo y basados en firma. Revisa el issue relacionado 1702 para consultar la solución propuesta anteriormente. Se considera terminado cuando Catch2 admita combinar parámetros de plantilla no tipo en tiempo de compilación como se solicita, y el enfoque compatible esté documentado y cubierto por tests relevantes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

There are various reasons why a class or function may have multiple non-type template parameters, including (but not limited to) compile-time feature toggling, guaranteed compile-time branch elimination, and multidimensional spans and containers with compile-time extents.

There are already two features that are close to the request, but none seem to satisfy it exactly:

  1. Generators allow going through a Cartesian product of inputs.
  2. Type parametrised test cases have TEMPLATE_PRODUCT_TEST_CASE for combining types, and signature-based parametrised tests allow traversing compile-time constants.
  3. TEMPLATE_LIST_TEST_CASE allows using an std::tuple to represent types. Using an std::tuple of constexpr values for TEMPLATE_TEST_CASE_SIG would allow for at least manual compile-time generation of all required combinations.

Evident limitations of these approaches in the context of the request:

  1. Generators do not support constexpr values, so they cannot be used for non-type template parameters.
  2. A signature-based parameterised test argument list grows exponentially with any additional argument that needs to be combined with the others.
  3. The template list test case does not support values directly. However, there is std::integral_constant, which is sufficient for a lot of applications, but not all, because non-type template parameters are not limited to integral constants.

Additional context

Another user already made a similar request and was satisfied with the proposed solution, but I cannot reopen it and am unsure whether a comment in the closed issue would be lost.

Lenguaje dominante
C++
Estrellas
21.6k
Forks
3.4k
Merge medio
3 d 12 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de catchorg/Catch2

Todos los issues de catchorg/Catch2

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.