Unverified Commit b9cec30c authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add test for exceptions with incompatible format

parent c6d04343
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "gmock/gmock.h"
#include "fmt/format.h"
#include <string>
#include <exception>

using namespace LAMMPS_NS;
using ::testing::Eq;
@@ -93,3 +94,13 @@ TEST(Fmtlib, insert_neg_double) {
    auto text = fmt::format("word {}",val);
    ASSERT_THAT(text, Eq("word -1.5"));
}

TEST(Fmtlib, int_for_double) {
    const double val = -1.5;
    ASSERT_THROW(fmt::format("word {:d}",val),std::exception);
}

TEST(Fmtlib, double_for_int) {
    const int val = 15;
    ASSERT_THROW(fmt::format("word {:g}",val),std::exception);
}