add test for exceptions with incompatible format
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
@ -93,3 +94,13 @@ TEST(Fmtlib, insert_neg_double) {
|
|||||||
auto text = fmt::format("word {}",val);
|
auto text = fmt::format("word {}",val);
|
||||||
ASSERT_THAT(text, Eq("word -1.5"));
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user