apply clang-format settings to the c++ sources in the unittest tree
This commit is contained in:
@ -11,114 +11,127 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "lmptype.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include <string>
|
||||
#include "lmptype.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using ::testing::Eq;
|
||||
|
||||
// this tests a subset of {fmt} that is most relevant to LAMMPS
|
||||
|
||||
TEST(FmtLib, insert_string) {
|
||||
TEST(FmtLib, insert_string)
|
||||
{
|
||||
const char val[] = "word";
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word word"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_int) {
|
||||
TEST(FmtLib, insert_int)
|
||||
{
|
||||
const int val = 333;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 333"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_int) {
|
||||
TEST(FmtLib, insert_neg_int)
|
||||
{
|
||||
const int val = -333;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -333"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_bigint) {
|
||||
TEST(FmtLib, insert_bigint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = 9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_bigint) {
|
||||
TEST(FmtLib, insert_neg_bigint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG)
|
||||
const bigint val = -9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_tagint) {
|
||||
TEST(FmtLib, insert_tagint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = 9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_tagint) {
|
||||
TEST(FmtLib, insert_neg_tagint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const tagint val = -9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_imageint) {
|
||||
TEST(FmtLib, insert_imageint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = 9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_imageint) {
|
||||
TEST(FmtLib, insert_neg_imageint)
|
||||
{
|
||||
#if defined(LAMMPS_BIGBIG)
|
||||
const imageint val = -9945234592L;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -9945234592"));
|
||||
#else
|
||||
GTEST_SKIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_double) {
|
||||
TEST(FmtLib, insert_double)
|
||||
{
|
||||
const double val = 1.5;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word 1.5"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, insert_neg_double) {
|
||||
TEST(FmtLib, insert_neg_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
auto text = fmt::format("word {}",val);
|
||||
auto text = fmt::format("word {}", val);
|
||||
ASSERT_THAT(text, Eq("word -1.5"));
|
||||
}
|
||||
|
||||
TEST(FmtLib, int_for_double) {
|
||||
TEST(FmtLib, int_for_double)
|
||||
{
|
||||
const double val = -1.5;
|
||||
ASSERT_THROW(fmt::format("word {:d}",val),std::exception);
|
||||
ASSERT_THROW(fmt::format("word {:d}", val), std::exception);
|
||||
}
|
||||
|
||||
TEST(FmtLib, double_for_int) {
|
||||
TEST(FmtLib, double_for_int)
|
||||
{
|
||||
const int val = 15;
|
||||
ASSERT_THROW(fmt::format("word {:g}",val),std::exception);
|
||||
ASSERT_THROW(fmt::format("word {:g}", val), std::exception);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user