xref: /third_party/json/tests/abi/config/config.hpp (revision c5f01b2f)
1//     __ _____ _____ _____
2//  __|  |   __|     |   | |  JSON for Modern C++ (supporting code)
3// |  |  |__   |  |  | | | |  version 3.11.2
4// |_____|_____|_____|_|___|  https://github.com/nlohmann/json
5//
6// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7// SPDX-License-Identifier: MIT
8
9#pragma once
10
11#include "doctest.h"
12
13#include <iostream>
14#include <regex>
15#include <string>
16
17#define STRINGIZE_EX(x) #x
18#define STRINGIZE(x) STRINGIZE_EX(x)
19
20template<typename T>
21std::string namespace_name(std::string ns, T* /*unused*/ = nullptr) // NOLINT(performance-unnecessary-value-param)
22{
23#if DOCTEST_MSVC && !DOCTEST_CLANG
24    ns = __FUNCSIG__;
25#elif !DOCTEST_CLANG
26    ns = __PRETTY_FUNCTION__;
27#endif
28    std::smatch m;
29
30    // extract the true namespace name from the function signature
31    CAPTURE(ns);
32    CHECK(std::regex_search(ns, m, std::regex("nlohmann(::[a-zA-Z0-9_]+)*::basic_json")));
33
34    return m.str();
35}
36