add test for exceptions with incompatible format

This commit is contained in:
Axel Kohlmeyer 2020-06-01 22:18:45 -04:00
parent c6d04343e3
commit b9cec30c2b
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 11 additions and 0 deletions

View File

@ -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);
}