Add a testcase demonstrating ODR violation in ranges.h

This commit is contained in:
Pierre-Antoine Lacaze 2021-09-01 22:16:45 +02:00
parent ee63f5f04e
commit 1d29a69139
2 changed files with 23 additions and 1 deletions

View File

@ -85,7 +85,7 @@ endif ()
add_fmt_test(ostream-test) add_fmt_test(ostream-test)
add_fmt_test(compile-test) add_fmt_test(compile-test)
add_fmt_test(printf-test) add_fmt_test(printf-test)
add_fmt_test(ranges-test) add_fmt_test(ranges-test ranges-odr-test.cc)
add_fmt_test(scan-test) add_fmt_test(scan-test)
add_fmt_test(unicode-test HEADER_ONLY) add_fmt_test(unicode-test HEADER_ONLY)
if (MSVC) if (MSVC)

22
test/ranges-odr-test.cc Normal file
View File

@ -0,0 +1,22 @@
// Formatting library for C++ - the core API
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
//
// Copyright (c) 2018 - present, Remotion (Igor Schulz)
// All Rights Reserved
// {fmt} support for ranges, containers and types tuple interface.
#include "fmt/ranges.h"
#include <vector>
#include "gtest/gtest.h"
TEST(ranges_odr_test, format_vector) {
auto v = std::vector<int>{1, 2, 3, 5, 7, 11};
EXPECT_EQ(fmt::format("{}", v), "[1, 2, 3, 5, 7, 11]");
}