STUB.h File Reference
#include <iostream>
Include dependency graph for STUB.h:

Go to the source code of this file.

Macros

#define stub_fatal(m)   { std::cerr<<"FATAL: "<<(m)<<" for use of "<<__FUNCTION__<<"\n"; exit(EXIT_FAILURE); }
 
#define STUB   { stub_fatal(STUB_API " required"); }
 macro to stub a void function. More...
 
#define STUB_NOP   { std::cerr<<"SKIP: "<<STUB_API<<" "<<__FUNCTION__<<" (not implemented).\n"; }
 
#define STUB_RETVAL(x)   { stub_fatal(STUB_API " required"); return x; }
 
#define STUB_RETVAL_NOP(x)   { std::cerr<<"SKIP: "<<STUB_API<<" "<<__FUNCTION__<<" (not implemented).\n"; return x; }
 
#define STUB_RETREF(x)   { stub_fatal(STUB_API " required"); return *(x *)nullptr; }
 
#define STUB_RETSTATREF(x)   STUB_RETREF(x)
 

Macro Definition Documentation

◆ STUB

#define STUB   { stub_fatal(STUB_API " required"); }

Definition at line 33 of file STUB.h.

◆ stub_fatal

#define stub_fatal (   m)    { std::cerr<<"FATAL: "<<(m)<<" for use of "<<__FUNCTION__<<"\n"; exit(EXIT_FAILURE); }

\group STUB

A set of useful macros to create stub_* files.

Intended for use building unit tests, if a stubbed function is called by any code it is linked to it will abort with a message indicating which API file is missing from the linked dependencies.

Usage: at the top of your intended stub file define STUB_API to be the name of the .cc file or library you are providing a stub of then include this STUB.h header.

#define STUB_API "foo/libexample.la" #include "tests/STUB.h"

Definition at line 30 of file STUB.h.

◆ STUB_NOP

#define STUB_NOP   { std::cerr<<"SKIP: "<<STUB_API<<" "<<__FUNCTION__<<" (not implemented).\n"; }

macro to stub a void function without a fatal message Intended for registration pattern APIs where the function result does not matter to the test

Definition at line 37 of file STUB.h.

◆ STUB_RETREF

#define STUB_RETREF (   x)    { stub_fatal(STUB_API " required"); return *(x *)nullptr; }

macro to stub a function which returns a reference to dynamic Aborts unit tests requiring its definition with a message about the missing linkage

Parameters
xunderlying or "referred to" type

Definition at line 51 of file STUB.h.

◆ STUB_RETSTATREF

#define STUB_RETSTATREF (   x)    STUB_RETREF(x)

Same as STUB_RETREF(). TODO: Remove

Definition at line 54 of file STUB.h.

◆ STUB_RETVAL

#define STUB_RETVAL (   x)    { stub_fatal(STUB_API " required"); return x; }

macro to stub a function with return value. Aborts unit tests requiring its definition with a message about the missing linkage

Definition at line 41 of file STUB.h.

◆ STUB_RETVAL_NOP

#define STUB_RETVAL_NOP (   x)    { std::cerr<<"SKIP: "<<STUB_API<<" "<<__FUNCTION__<<" (not implemented).\n"; return x; }

macro to stub a void function without a fatal message and with a return value Intended for registration pattern APIs where the function result does not matter to the test

Definition at line 45 of file STUB.h.

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors