/* * Copyright (C) 1996-2023 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ #ifndef SQUID_SRC_TESTS_STUB_H #define SQUID_SRC_TESTS_STUB_H /** \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" */ #include // Internal Special: the STUB framework requires this function #define stub_fatal(m) { std::cerr<<"FATAL: "<<(m)<<" for use of "<<__FUNCTION__<<"\n"; exit(EXIT_FAILURE); } /// macro to stub a void function. #define STUB { stub_fatal(STUB_API " required"); } /// 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 #define STUB_NOP { std::cerr<<"SKIP: "<