From 165708adeb487966281048127645595fa110d0e8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 12 Oct 2021 22:52:50 -0400 Subject: [PATCH] use nullptr in unittest tree --- unittest/cplusplus/test_lammps_class.cpp | 17 +++++++++-------- unittest/force-styles/test_main.cpp | 2 +- unittest/force-styles/yaml_writer.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/unittest/cplusplus/test_lammps_class.cpp b/unittest/cplusplus/test_lammps_class.cpp index fa7f6b30a9..663c7358d9 100644 --- a/unittest/cplusplus/test_lammps_class.cpp +++ b/unittest/cplusplus/test_lammps_class.cpp @@ -108,21 +108,22 @@ TEST_F(LAMMPS_plain, TestStyles) const char *found; const char *atom_styles[] = {"atomic", "body", "charge", "ellipsoid", "hybrid", - "line", "sphere", "tri", NULL}; - for (int i = 0; atom_styles[i] != NULL; ++i) { + "line", "sphere", "tri", nullptr}; + for (int i = 0; atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", atom_styles[i]); - EXPECT_STREQ(found, NULL); + EXPECT_STREQ(found, nullptr); } - const char *molecule_atom_styles[] = {"angle", "bond", "full", "molecular", "template", NULL}; - for (int i = 0; molecule_atom_styles[i] != NULL; ++i) { + const char *molecule_atom_styles[] = {"angle", "bond", "full", + "molecular", "template", nullptr}; + for (int i = 0; molecule_atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", molecule_atom_styles[i]); EXPECT_STREQ(found, "MOLECULE"); } const char *kokkos_atom_styles[] = {"angle/kk", "bond/kk", "full/kk", - "molecular/kk", "hybrid/kk", NULL}; - for (int i = 0; kokkos_atom_styles[i] != NULL; ++i) { + "molecular/kk", "hybrid/kk", nullptr}; + for (int i = 0; kokkos_atom_styles[i] != nullptr; ++i) { found = lmp->match_style("atom", kokkos_atom_styles[i]); EXPECT_STREQ(found, "KOKKOS"); } @@ -149,7 +150,7 @@ TEST_F(LAMMPS_plain, TestStyles) found = lmp->match_style("atom", "sph"); EXPECT_STREQ(found, "SPH"); found = lmp->match_style("atom", "i_don't_exist"); - EXPECT_STREQ(found, NULL); + EXPECT_STREQ(found, nullptr); } // test fixture for OpenMP with 2 threads diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index 5b2663a6cf..1ad0b79455 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -47,7 +47,7 @@ void write_yaml_header(YamlWriter *writer, TestConfig *cfg, const char *version) writer->emit("lammps_version", version); // date_generated - std::time_t now = time(NULL); + std::time_t now = time(nullptr); std::string block = trim(ctime(&now)); writer->emit("date_generated", block); diff --git a/unittest/force-styles/yaml_writer.cpp b/unittest/force-styles/yaml_writer.cpp index feaa3d52eb..b1165ff821 100644 --- a/unittest/force-styles/yaml_writer.cpp +++ b/unittest/force-styles/yaml_writer.cpp @@ -31,9 +31,9 @@ YamlWriter::YamlWriter(const char *outfile) yaml_stream_start_event_initialize(&event, YAML_UTF8_ENCODING); yaml_emitter_emit(&emitter, &event); - yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0); + yaml_document_start_event_initialize(&event, nullptr, nullptr, nullptr, 0); yaml_emitter_emit(&emitter, &event); - yaml_mapping_start_event_initialize(&event, NULL, (yaml_char_t *)YAML_MAP_TAG, 1, + yaml_mapping_start_event_initialize(&event, nullptr, (yaml_char_t *)YAML_MAP_TAG, 1, YAML_ANY_MAPPING_STYLE); yaml_emitter_emit(&emitter, &event); } @@ -67,11 +67,11 @@ void YamlWriter::emit(const std::string &key, const int value) void YamlWriter::emit(const std::string &key, const std::string &value) { - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)key.c_str(), key.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)value.c_str(), value.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); @@ -79,11 +79,11 @@ void YamlWriter::emit(const std::string &key, const std::string &value) void YamlWriter::emit_block(const std::string &key, const std::string &value) { - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)key.c_str(), key.size(), 1, 0, YAML_PLAIN_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event); - yaml_scalar_event_initialize(&event, NULL, (yaml_char_t *)YAML_STR_TAG, + yaml_scalar_event_initialize(&event, nullptr, (yaml_char_t *)YAML_STR_TAG, (yaml_char_t *)value.c_str(), value.size(), 1, 0, YAML_LITERAL_SCALAR_STYLE); yaml_emitter_emit(&emitter, &event);