diff --git a/src/ADIOS/adios_common.h b/src/ADIOS/adios_common.h index 3345b1e0713..fcddf8faed6 100644 --- a/src/ADIOS/adios_common.h +++ b/src/ADIOS/adios_common.h @@ -16,24 +16,9 @@ #ifndef LMP_ADIOS_COMMON_H #define LMP_ADIOS_COMMON_H -// common definitions for all ADIOS package classes - -static const char default_config[] = "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n"; +// common definition for all ADIOS package classes +namespace LAMMPS_ADIOS { +extern const char *default_config; +} #endif diff --git a/src/ADIOS/dump_atom_adios.cpp b/src/ADIOS/dump_atom_adios.cpp index 0c2e46ca59c..c5aefb23561 100644 --- a/src/ADIOS/dump_atom_adios.cpp +++ b/src/ADIOS/dump_atom_adios.cpp @@ -32,6 +32,28 @@ #include "adios_common.h" using namespace LAMMPS_NS; +using namespace LAMMPS_ADIOS; + +// common definition for all ADIOS package classes + +const char *LAMMPS_ADIOS::default_config = + (const char *) "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; namespace LAMMPS_NS { class DumpAtomADIOSInternal { @@ -235,24 +257,29 @@ void DumpAtomADIOS::init_style() // setup column string - std::vector columnNames; - - if (scale_flag == 0 && image_flag == 0) { - columns = (char *) "id type x y z"; - columnNames = {"id", "type", "x", "y", "z"}; - } else if (scale_flag == 0 && image_flag == 1) { - columns = (char *) "id type x y z ix iy iz"; - columnNames = {"id", "type", "x", "y", "z", "ix", "iy", "iz"}; - } else if (scale_flag == 1 && image_flag == 0) { - columns = (char *) "id type xs ys zs"; - columnNames = {"id", "type", "xs", "ys", "zs"}; - } else if (scale_flag == 1 && image_flag == 1) { - columns = (char *) "id type xs ys zs ix iy iz"; - columnNames = {"id", "type", "xs", "ys", "zs", "ix", "iy", "iz"}; - } + std::string default_columns; - for (int icol = 0; icol < (int) columnNames.size(); ++icol) - if (keyword_user[icol].size()) columnNames[icol] = keyword_user[icol]; + if (scale_flag == 0 && image_flag == 0) + default_columns = "id type x y z"; + else if (scale_flag == 0 && image_flag == 1) + default_columns = "id type x y z ix iy iz"; + else if (scale_flag == 1 && image_flag == 0) + default_columns = "id type xs ys zs"; + else if (scale_flag == 1 && image_flag == 1) + default_columns = "id type xs ys zs ix iy iz"; + + std::vector columnNames = utils::split_words(default_columns); + + int icol = 0; + columns.clear(); + for (const auto &item : columnNames) { + if (columns.size()) columns += " "; + if (keyword_user[icol].size()) + columns += keyword_user[icol]; + else + columns += item; + ++icol; + } // setup function ptrs diff --git a/src/ADIOS/dump_custom_adios.cpp b/src/ADIOS/dump_custom_adios.cpp index d1f67928b97..587727050b7 100644 --- a/src/ADIOS/dump_custom_adios.cpp +++ b/src/ADIOS/dump_custom_adios.cpp @@ -36,6 +36,7 @@ #include "adios_common.h" using namespace LAMMPS_NS; +using namespace LAMMPS_ADIOS; namespace LAMMPS_NS { class DumpCustomADIOSInternal { @@ -80,7 +81,7 @@ DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpCustom } internal->columnNames.reserve(nfield); - for (int i = 0; i < nfield; ++i) { internal->columnNames.emplace_back(earg[i]); } + for (int i = 0; i < nfield; ++i) internal->columnNames.emplace_back(earg[i]); } /* ---------------------------------------------------------------------- */ @@ -88,7 +89,7 @@ DumpCustomADIOS::DumpCustomADIOS(LAMMPS *lmp, int narg, char **arg) : DumpCustom DumpCustomADIOS::~DumpCustomADIOS() { internal->columnNames.clear(); - if (internal->fh) { internal->fh.Close(); } + if (internal->fh) internal->fh.Close(); delete internal->ad; delete internal; } @@ -216,10 +217,10 @@ void DumpCustomADIOS::write() internal->fh.Put("nme", bnme); internal->fh.Put("offset", atomOffset); // now write the atoms - internal->fh.Put("atoms", buf); + internal->fh.Put(internal->varAtoms, buf); internal->fh.EndStep(); // I/O will happen now... - if (multifile) { internal->fh.Close(); } + if (multifile) internal->fh.Close(); } /* ---------------------------------------------------------------------- */ diff --git a/src/ADIOS/reader_adios.cpp b/src/ADIOS/reader_adios.cpp index ac90d652617..51a5bb0ece9 100644 --- a/src/ADIOS/reader_adios.cpp +++ b/src/ADIOS/reader_adios.cpp @@ -30,6 +30,7 @@ #include "adios_common.h" using namespace LAMMPS_NS; +using namespace LAMMPS_ADIOS; static constexpr double SMALL = 1.0e-6; diff --git a/src/EXTRA-COMMAND/group2ndx.cpp b/src/EXTRA-COMMAND/group2ndx.cpp index e48b1288249..87beec24c73 100644 --- a/src/EXTRA-COMMAND/group2ndx.cpp +++ b/src/EXTRA-COMMAND/group2ndx.cpp @@ -61,7 +61,9 @@ void Group2Ndx::command(int narg, char **arg) } if (narg == 1) { // write out all groups - for (int i = 0; i < group->ngroup; ++i) { write_group(fp, i); } + for (int i = 0; i < Group::MAX_GROUP; ++i) { + if (group->names[i]) write_group(fp, i); + } } else { // write only selected groups for (int i = 1; i < narg; ++i) { int gid = group->find(arg[i]); diff --git a/src/GRAPHICS/image.cpp b/src/GRAPHICS/image.cpp index 9ab3e584900..c963254cc2d 100644 --- a/src/GRAPHICS/image.cpp +++ b/src/GRAPHICS/image.cpp @@ -52,6 +52,7 @@ namespace { constexpr int NCOLORS = 140; constexpr int NELEMENTS = 109; constexpr double EPSILON = 1.0e-6; +constexpr double TRANS_DELTA = 0.01; enum { NUMERIC, MINVALUE, MAXVALUE }; enum { CONTINUOUS, DISCRETE, SEQUENTIAL }; @@ -888,9 +889,9 @@ void Image::draw_pixmap(int xc, int yc, int pixwidth, int pixheight, const unsig // we allow a few steps difference for each channel to account // for rounding errors and reduce "bleeding" from interpolation - if ((fabs(pixelcolor[0] - transcolor[0]) < 0.01) && - (fabs(pixelcolor[1] - transcolor[1]) < 0.01) && - (fabs(pixelcolor[2] - transcolor[2]) < 0.01)) continue; + if ((fabs(pixelcolor[0] - transcolor[0]) < TRANS_DELTA) && + (fabs(pixelcolor[1] - transcolor[1]) < TRANS_DELTA) && + (fabs(pixelcolor[2] - transcolor[2]) < TRANS_DELTA)) continue; draw_pixel(ix, iy, dist, normal, pixelcolor); } @@ -1359,6 +1360,7 @@ void Image::draw_pixel(int ix, int iy, double depth, const double *surface, const double *surfaceColor) { if (!std::isfinite(depth)) return; // reject pixels with invalid depth buffer values + if (!surfaceColor) return; // reject pixels with an invalid color double diffuseKey,diffuseFill,diffuseBack,specularKey; if (depth < 0 || (depthBuffer[ix + iy*width] >= 0 && depth >= depthBuffer[ix + iy*width])) return; @@ -2552,5 +2554,6 @@ double *ColorMap::value2color(double value) return mentry[ibin%nentry].color; } - return nullptr; + // always return a non-NULL pointer + return mentry[0].color; } diff --git a/src/KOKKOS/atom_vec_ellipsoid_kokkos.cpp b/src/KOKKOS/atom_vec_ellipsoid_kokkos.cpp index 299e2a23ba0..894e60eee8b 100644 --- a/src/KOKKOS/atom_vec_ellipsoid_kokkos.cpp +++ b/src/KOKKOS/atom_vec_ellipsoid_kokkos.cpp @@ -944,7 +944,7 @@ void AtomVecEllipsoidKokkos::sync_pinned(ExecutionSpace space, uint64_t mask, in if ((mask & V_MASK) && atomKK->k_v.need_sync_device()) perform_pinned_copy_transform(atomKK->k_v,space,async_flag); if ((mask & F_MASK) && atomKK->k_f.need_sync_device()) - perform_pinned_copy_transform(atomKK->k_f,space,async_flag); + perform_pinned_copy_transform(atomKK->k_f,space,async_flag); if ((mask & TAG_MASK) && atomKK->k_tag.need_sync_device()) perform_pinned_copy(atomKK->k_tag,space,async_flag); if ((mask & TYPE_MASK) && atomKK->k_type.need_sync_device()) @@ -958,7 +958,7 @@ void AtomVecEllipsoidKokkos::sync_pinned(ExecutionSpace space, uint64_t mask, in if ((mask & ANGMOM_MASK) && atomKK->k_angmom.need_sync_device()) perform_pinned_copy_transform(atomKK->k_angmom,space,async_flag); if ((mask & TORQUE_MASK) && atomKK->k_torque.need_sync_device()) - perform_pinned_copy_transform(atomKK->k_torque,space,async_flag); + perform_pinned_copy_transform(atomKK->k_torque,space,async_flag); if ((mask & ELLIPSOID_MASK) && atomKK->k_ellipsoid.need_sync_device()) perform_pinned_copy(atomKK->k_ellipsoid,space,async_flag); if ((mask & BONUS_MASK) && k_bonus.need_sync_device()) @@ -969,7 +969,7 @@ void AtomVecEllipsoidKokkos::sync_pinned(ExecutionSpace space, uint64_t mask, in if ((mask & V_MASK) && atomKK->k_v.need_sync_host()) perform_pinned_copy_transform(atomKK->k_v,space,async_flag); if ((mask & F_MASK) && atomKK->k_f.need_sync_host()) - perform_pinned_copy_transform(atomKK->k_f,space,async_flag); + perform_pinned_copy_transform(atomKK->k_f,space,async_flag); if ((mask & TAG_MASK) && atomKK->k_tag.need_sync_host()) perform_pinned_copy(atomKK->k_tag,space,async_flag); if ((mask & TYPE_MASK) && atomKK->k_type.need_sync_host()) @@ -983,7 +983,7 @@ void AtomVecEllipsoidKokkos::sync_pinned(ExecutionSpace space, uint64_t mask, in if ((mask & ANGMOM_MASK) && atomKK->k_angmom.need_sync_host()) perform_pinned_copy_transform(atomKK->k_angmom,space,async_flag); if ((mask & TORQUE_MASK) && atomKK->k_torque.need_sync_host()) - perform_pinned_copy_transform(atomKK->k_torque,space,async_flag); + perform_pinned_copy_transform(atomKK->k_torque,space,async_flag); if ((mask & ELLIPSOID_MASK) && atomKK->k_ellipsoid.need_sync_host()) perform_pinned_copy(atomKK->k_ellipsoid,space,async_flag); if ((mask & BONUS_MASK) && k_bonus.need_sync_host()) diff --git a/src/KOKKOS/atom_vec_ellipsoid_kokkos.h b/src/KOKKOS/atom_vec_ellipsoid_kokkos.h index 65d280847fe..a87c9935091 100644 --- a/src/KOKKOS/atom_vec_ellipsoid_kokkos.h +++ b/src/KOKKOS/atom_vec_ellipsoid_kokkos.h @@ -132,14 +132,14 @@ class AtomVecEllipsoidKokkos : public AtomVecKokkos, public AtomVecEllipsoid { DAT::t_kkfloat_1d_3_lr d_x; DAT::t_kkfloat_1d_3 d_v; - DAT::t_kkfloat_1d_3 d_f; + DAT::t_kkacc_1d_3 d_f; DAT::t_kkfloat_1d d_rmass; HAT::t_kkfloat_1d h_rmass; DAT::t_kkfloat_1d_3 d_angmom; HAT::t_kkfloat_1d_3 h_angmom; - DAT::t_kkfloat_1d_3 d_torque; - HAT::t_kkfloat_1d_3 h_torque; + DAT::t_kkacc_1d_3 d_torque; + HAT::t_kkacc_1d_3 h_torque; DAT::t_int_1d d_ellipsoid; HAT::t_int_1d h_ellipsoid; diff --git a/src/KOKKOS/bond_hybrid_kokkos.h b/src/KOKKOS/bond_hybrid_kokkos.h index 217beaca5f6..8594d211f74 100644 --- a/src/KOKKOS/bond_hybrid_kokkos.h +++ b/src/KOKKOS/bond_hybrid_kokkos.h @@ -46,7 +46,7 @@ class BondHybridKokkos : public BondHybrid { DAT::tdual_int_1d k_map; // which style each bond type points to DAT::tdual_int_1d k_nbondlist; // # of bonds in sub-style bondlists - DAT::tdual_int_3d k_bondlist; // bondlist for each sub-style + DAT::tdual_int_3d_lr k_bondlist; // bondlist for each sub-style void allocate() override; void deallocate() override; diff --git a/src/KOKKOS/dihedral_hybrid_kokkos.h b/src/KOKKOS/dihedral_hybrid_kokkos.h index 63a59505afe..e88dfe989e8 100644 --- a/src/KOKKOS/dihedral_hybrid_kokkos.h +++ b/src/KOKKOS/dihedral_hybrid_kokkos.h @@ -46,7 +46,7 @@ class DihedralHybridKokkos : public DihedralHybrid { DAT::tdual_int_1d k_map; // which style each dihedral type points to DAT::tdual_int_1d k_ndihedrallist; // # of dihedrals in sub-style dihedrallists - DAT::tdual_int_3d k_dihedrallist; // dihedrallist for each sub-style + DAT::tdual_int_3d_lr k_dihedrallist; // dihedrallist for each sub-style void allocate() override; void deallocate() override; diff --git a/src/KOKKOS/fix_langevin_kokkos.h b/src/KOKKOS/fix_langevin_kokkos.h index 67ced3bbed0..4faad64960e 100644 --- a/src/KOKKOS/fix_langevin_kokkos.h +++ b/src/KOKKOS/fix_langevin_kokkos.h @@ -144,7 +144,7 @@ namespace LAMMPS_NS { // For angmom thermostat class AtomVecEllipsoidKokkos *avecEllipKK; typename AtomVecEllipsoidKokkosBonusArray::t_bonus_1d bonus; - typename ArrayTypes::t_kkfloat_1d_3 torque; + typename ArrayTypes::t_kkacc_1d_3 torque; typename ArrayTypes::t_kkfloat_1d_3 angmom; typename ArrayTypes::t_int_1d ellipsoid; void angmom_thermostat(); diff --git a/src/KOKKOS/fix_nve_asphere_kokkos.h b/src/KOKKOS/fix_nve_asphere_kokkos.h index 744a9e41e09..68556b0f046 100644 --- a/src/KOKKOS/fix_nve_asphere_kokkos.h +++ b/src/KOKKOS/fix_nve_asphere_kokkos.h @@ -54,9 +54,9 @@ class FixNVEAsphereKokkos : public FixNVEAsphere { typename ArrayTypes::t_int_1d ellipsoid; typename ArrayTypes::t_kkfloat_1d_3_lr x; typename ArrayTypes::t_kkfloat_1d_3 v; - typename ArrayTypes::t_kkfloat_1d_3 f; + typename ArrayTypes::t_kkacc_1d_3 f; typename ArrayTypes::t_kkfloat_1d_3 angmom; - typename ArrayTypes::t_kkfloat_1d_3 torque; + typename ArrayTypes::t_kkacc_1d_3 torque; typename ArrayTypes::t_kkfloat_1d rmass; typename ArrayTypes::t_int_1d mask; }; diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index 1c52e47b6b1..13ee3341cc2 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -447,7 +447,7 @@ void FixShakeKokkos::operator()(TagFixShakeMinPostForceall(FLERR,"Molecule update not implemented for fix {}", style); } diff --git a/src/group.cpp b/src/group.cpp index 4ee2dd79c3d..14bc5096ee2 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -39,7 +39,6 @@ using namespace LAMMPS_NS; -static constexpr int MAX_GROUP = 32; static constexpr double EPSILON = 1.0e-6; enum { NONE, TYPE, MOLECULE, ID }; @@ -152,7 +151,7 @@ void Group::assign(int narg, char **arg) bool created = false; if (igroup == -1) { - if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", MAX_GROUP); + if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", int(MAX_GROUP)); igroup = find_unused(); names[igroup] = utils::strdup(arg[0]); ngroup++; @@ -592,7 +591,7 @@ void Group::create(const std::string &name, int *flag) int igroup = find(name); if (igroup == -1) { - if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", MAX_GROUP); + if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", int(MAX_GROUP)); igroup = find_unused(); names[igroup] = utils::strdup(name); ngroup++; @@ -629,7 +628,7 @@ int Group::find_or_create(const char *name) int igroup = find(name); if (igroup >= 0) return igroup; - if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", MAX_GROUP); + if (ngroup == MAX_GROUP) error->all(FLERR, "Too many groups (max {})", int(MAX_GROUP)); igroup = find_unused(); names[igroup] = utils::strdup(name); ngroup++; diff --git a/src/group.h b/src/group.h index 2c927a141d9..fd2c15857ad 100644 --- a/src/group.h +++ b/src/group.h @@ -23,11 +23,12 @@ class Group : protected Pointers { friend class FixGroup; public: - int ngroup; // # of defined groups - char **names; // name of each group - int *bitmask; // one-bit mask for each group - int *inversemask; // inverse mask for each group - int *dynamic; // 1 if dynamic, 0 if not + enum { MAX_GROUP = 32 }; // max # of groups. limited to 32 because bitmasks are 32-bit int. + int ngroup; // # of defined groups + char **names; // name of each group + int *bitmask; // one-bit mask for each group + int *inversemask; // inverse mask for each group + int *dynamic; // 1 if dynamic, 0 if not Group(class LAMMPS *); ~Group() override; diff --git a/src/info.cpp b/src/info.cpp index 8b83be4cd27..e5febf093d0 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -494,10 +494,12 @@ void Info::command(int narg, char **arg) char **names = group->names; int *dynamic = group->dynamic; fputs("\nGroup information:\n",out); - for (int i=0; i < ngroup; ++i) { - if (names[i]) + for (int i=0; i < Group::MAX_GROUP; ++i) { + // skip over deleted groups + if (names[i]) { utils::print(out,"Group[{:2d}]: {:16} ({})\n", - i, names[i], dynamic[i] ? "dynamic" : "static"); + i, names[i], dynamic[i] ? "dynamic" : "static"); + } } } diff --git a/src/library.cpp b/src/library.cpp index 29cc81867da..5c6962c05f0 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -71,9 +71,6 @@ /// string buffer for error messages of global errors static std::string lammps_last_global_errormessage; -/// maximum number of groups -static constexpr int LMP_MAX_GROUP = 32; - using namespace LAMMPS_NS; // for printing the non-null pointer argument warning only once @@ -1338,6 +1335,9 @@ be called without a valid LAMMPS object handle (it is ignored). * - imageint - size of the ``imageint`` integer type, 4 or 8 bytes. Set at :ref:`compile time `. + * - MAX_GROUP + - size of the bitmask for groups in bits, should be 32. + Currently hard coded. .. _extract_image_masks: @@ -1558,6 +1558,8 @@ int lammps_extract_setting(void *handle, const char *keyword) if (strcmp(keyword,"tagint") == 0) return sizeof(tagint); if (strcmp(keyword,"imageint") == 0) return sizeof(imageint); + if (strcmp(keyword,"MAX_GROUP") == 0) return Group::MAX_GROUP; + if (strcmp(keyword,"IMGMASK") == 0) return IMGMASK; if (strcmp(keyword,"IMGBITS") == 0) return IMGBITS; if (strcmp(keyword,"IMG2BITS") == 0) return IMG2BITS; @@ -7227,7 +7229,7 @@ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, in } } else if (strcmp(category,"group") == 0) { // the list of groups may have "holes". So the available range is always 0 to 32 - if ((idx >= 0) && (idx < LMP_MAX_GROUP)) { + if ((idx >= 0) && (idx < Group::MAX_GROUP)) { if (lmp->group->names[idx]) { strncpy(buffer, lmp->group->names[idx], buf_size); return 1; diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 73de684d5d5..3aa9fef6799 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -1292,10 +1292,6 @@ int ReadDump::fields_and_keywords(int narg, char **arg) if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "read_dump format", error); delete[] readerstyle; readerstyle = utils::strdup(arg[iarg+1]); - // adjust first field type added by default depending on format - if (strcmp(readerstyle, "xyz") == 0) fieldtype[0] = Reader::TYPE; - if (strcmp(readerstyle, "native") == 0) fieldtype[0] = Reader::ID; - if (strcmp(readerstyle, "molfile") == 0) fieldtype[0] = Reader::TYPE; iarg += 2; break; } else error->all(FLERR,"Unknown read_dump keyword: {}",arg[iarg]); diff --git a/unittest/force-styles/tests/fix-timestep-deform_tri.yaml b/unittest/force-styles/tests/fix-timestep-deform_tri.yaml index c023c600340..7b08f571cd7 100644 --- a/unittest/force-styles/tests/fix-timestep-deform_tri.yaml +++ b/unittest/force-styles/tests/fix-timestep-deform_tri.yaml @@ -1,7 +1,7 @@ --- lammps_version: 22 Dec 2022 date_generated: Sun Jan 1 12:06:17 2023 -epsilon: 5e-13 +epsilon: 2.0e-12 skip_tests: prerequisites: ! | atom full diff --git a/unittest/force-styles/tests/fix-timestep-rigid_nvt.yaml b/unittest/force-styles/tests/fix-timestep-rigid_nvt.yaml index f15e2a3c7fa..886c8100fc9 100644 --- a/unittest/force-styles/tests/fix-timestep-rigid_nvt.yaml +++ b/unittest/force-styles/tests/fix-timestep-rigid_nvt.yaml @@ -2,7 +2,7 @@ lammps_version: 7 Feb 2024 tags: date_generated: Thu Apr 4 21:27:14 2024 -epsilon: 1e-12 +epsilon: 2e-12 skip_tests: prerequisites: ! | atom full diff --git a/unittest/force-styles/tests/kspace-pppm_conp_charge.yaml b/unittest/force-styles/tests/kspace-pppm_conp_charge.yaml index 38161ee0440..7908a69a6ea 100644 --- a/unittest/force-styles/tests/kspace-pppm_conp_charge.yaml +++ b/unittest/force-styles/tests/kspace-pppm_conp_charge.yaml @@ -1,7 +1,7 @@ --- lammps_version: 7 Feb 2024 date_generated: Mon Mar 4 09:44:31 2024 -epsilon: 3e-12 +epsilon: 5.0e-12 skip_tests: gpu kokkos_omp omp prerequisites: ! | atom full diff --git a/unittest/formats/test_file_operations.cpp b/unittest/formats/test_file_operations.cpp index 3d6ab281fc8..2319cfc4d83 100644 --- a/unittest/formats/test_file_operations.cpp +++ b/unittest/formats/test_file_operations.cpp @@ -26,6 +26,8 @@ using namespace LAMMPS_NS; using testing::StrEq; +using testing::StartsWith; +using testing::EndsWith; using utils::read_lines_from_file; using utils::sfgets; @@ -233,7 +235,7 @@ TEST_F(FileOperationsTest, read_lines_from_file) TEST_F(FileOperationsTest, logmesg) { - char buf[64]; + char buf[128]; BEGIN_HIDE_OUTPUT(); command("echo none"); END_HIDE_OUTPUT(); @@ -247,12 +249,15 @@ TEST_F(FileOperationsTest, logmesg) utils::logmesg(lmp, "six {}\n"); command("log none"); std::string out = END_CAPTURE_OUTPUT(); - memset(buf, 0, 64); + memset(buf, 0, 128); FILE *fp = fopen("test_logmesg.log", "r"); - fread(buf, 1, 64, fp); + fread(buf, 1, 128, fp); fclose(fp); - ASSERT_THAT(out, StrEq("one\ntwo\nthree=3\nargument not found\nfive\nsix {}\n")); - ASSERT_THAT(buf, StrEq("two\nthree=3\nargument not found\nfive\nsix {}\n")); + + ASSERT_THAT(out,StartsWith("one\ntwo\nthree=3\n")); + ASSERT_THAT(out,EndsWith("\nfive\nsix {}\n")); + ASSERT_THAT(buf,StartsWith("two\nthree=3\n")); + ASSERT_THAT(buf,EndsWith("\nfive\nsix {}\n")); remove("test_logmesg.log"); }