Unit Testing Template For Etlin

  1. Etlin Daniels
  2. Unit Testing Template For Etlinx

Unit testing deals with testing a unit as a whole. This would test the interaction of many functions but confine the test within one unit. The exact scope of a unit is left to interpretation. Supporting test code, sometimes called scaffolding, may be necessary to support an individual test. The Test Strategy document describes the scope, approach, resources and schedule for the testing activities of the project. This includes defining what will be tested, who will perform testing, how testing will be managed, and the associated risks and contingencies. The Test Strategy document is maintained throughout the life of a project.

Active3 years, 2 months ago

Imagine that I have a lot of template code that I can test with static_asserts, so for example

Unit

Is the only way to test this by making a main.cpp that just includes this header and compiling it? -fsyntax-only did not seem to work.

CuriousCurious
12.2k2 gold badges27 silver badges81 bronze badges

2 Answers

Using the fact gcc and clang both can read stdin:

Step by step:

For
  • -c - compile but not link

  • -o /dev/null - do not produce any output files

  • -xc++ - source type would be C++

  • - - source given as stdin

  • <header.h - supply your header file as input

Daniels

Note that you must also pass any relevant to your project -D or -I flags.

To fix warning about #pragma once in main file, you can either:

  • Suppress it, if your compiler supports -Wpragma-once-outside-header

  • Feed header indirectly with echo:

    echo '#include 'header.h' clang -c -o /dev/null -xc++ -

Etlin Daniels

Pdf converter install. Do not forget the trailing -.

denissdeniss
4,9162 gold badges13 silver badges28 bronze badges

Well, lest's assume you have a testing framework like gtest, I'd try to write a test like

πάντα ῥεῖπάντα ῥεῖ

Unit Testing Template For Etlinx

Not the answer you're looking for? Browse other questions tagged c++unit-testingtemplatesconstraintstemplate-meta-programming or ask your own question.

Posted on