From 1d29a69139b86eea21fc99c6fc3ecbf9dc000027 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Lacaze Date: Wed, 1 Sep 2021 22:16:45 +0200 Subject: [PATCH] Add a testcase demonstrating ODR violation in ranges.h --- test/CMakeLists.txt | 2 +- test/ranges-odr-test.cc | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/ranges-odr-test.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bf3785a6..6bf68fb3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -85,7 +85,7 @@ endif () add_fmt_test(ostream-test) add_fmt_test(compile-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(unicode-test HEADER_ONLY) if (MSVC) diff --git a/test/ranges-odr-test.cc b/test/ranges-odr-test.cc new file mode 100644 index 00000000..3ecba1b9 --- /dev/null +++ b/test/ranges-odr-test.cc @@ -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 + +#include "gtest/gtest.h" + +TEST(ranges_odr_test, format_vector) { + auto v = std::vector{1, 2, 3, 5, 7, 11}; + EXPECT_EQ(fmt::format("{}", v), "[1, 2, 3, 5, 7, 11]"); +} +