Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016-2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * |
| 4 | * Written by Jan Kundrát <jan.kundrat@cesnet.cz> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <doctest/doctest.h> |
| 11 | #include <map> |
| 12 | #include <sstream> |
| 13 | #include <trompeloeil.hpp> |
| 14 | |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 15 | namespace doctest { |
| 16 | |
| 17 | template <> |
| 18 | struct StringMaker<std::map<std::string, std::string>> { |
| 19 | static String convert(const std::map<std::string, std::string>& map) |
| 20 | { |
| 21 | std::ostringstream os; |
| 22 | os << "{" << std::endl; |
| 23 | for (const auto& [key, value] : map) { |
| 24 | os << " \"" << key << "\": \"" << value << "\"," << std::endl; |
| 25 | } |
| 26 | os << "}"; |
| 27 | return os.str().c_str(); |
| 28 | } |
| 29 | }; |
| 30 | |
Tomáš Pecka | 9b1c967 | 2020-11-11 15:24:06 +0100 | [diff] [blame] | 31 | template <> |
| 32 | struct StringMaker<std::map<std::string, int64_t>> { |
| 33 | static String convert(const std::map<std::string, int64_t>& map) |
| 34 | { |
| 35 | std::ostringstream os; |
| 36 | os << "{" << std::endl; |
| 37 | for (const auto& [key, value] : map) { |
| 38 | os << " \"" << key << "\": " << value << "," << std::endl; |
| 39 | } |
| 40 | os << "}"; |
| 41 | return os.str().c_str(); |
| 42 | } |
| 43 | }; |
| 44 | |
Tomáš Pecka | 491f4f2 | 2020-11-05 15:44:00 +0100 | [diff] [blame] | 45 | } |