Some refactoring of tests

This commit is contained in:
Richard Berger
2020-08-13 18:04:34 -04:00
parent dbcf66cf97
commit 1b60f876e0
2 changed files with 32 additions and 24 deletions

View File

@ -177,55 +177,63 @@ TEST_F(DumpAtomTest, binary_with_units_run0)
{ {
if(!BINARY2TXT_BINARY) GTEST_SKIP(); if(!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_text_with_units_run0.melt";
auto binary_file = "dump_binary_with_units_run0.melt.bin";
auto converted_file = fmt::format("{}.txt", binary_file);
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
command("dump id0 all atom 1 dump_text_with_units_run0.melt"); command(fmd::format("dump id0 all atom 1 {}", text_file));
command("dump id1 all atom 1 dump_binary_with_units_run0.melt.bin"); command(fmt::format("dump id1 all atom 1 {}", binary_file));
command("dump_modify id0 scale no units yes"); command("dump_modify id0 scale no units yes");
command("dump_modify id1 scale no units yes"); command("dump_modify id1 scale no units yes");
command("run 0"); command("run 0");
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_text_with_units_run0.melt"); ASSERT_FILE_EXISTS(text_file);
ASSERT_FILE_EXISTS("dump_binary_with_units_run0.melt.bin"); ASSERT_FILE_EXISTS(binary_file);
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
std::string cmdline = fmt::format("{} dump_binary_with_units_run0.melt.bin", BINARY2TXT_BINARY); std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
system(cmdline.c_str()); system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_binary_with_units_run0.melt.bin.txt"); ASSERT_FILE_EXISTS(converted_file);
ASSERT_FILE_EQUAL("dump_text_with_units_run0.melt", "dump_binary_with_units_run0.melt.bin.txt"); ASSERT_FILE_EQUAL(text_file, converted_file);
delete_file("dump_text_with_units_run0.melt"); delete_file(text_file);
delete_file("dump_binary_with_units_run0.melt.bin"); delete_file(binary_file);
delete_file("dump_binary_with_units_run0.melt.bin.txt"); delete_file(converted_file);
} }
TEST_F(DumpAtomTest, binary_triclinic_with_units_run0) TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
{ {
if(!BINARY2TXT_BINARY) GTEST_SKIP(); if(!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_text_tri_with_units_run0.melt";
auto binary_file = "dump_binary_tri_with_units_run0.melt.bin";
auto converted_file = fmt::format("{}.txt", binary_file);
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
command("change_box all triclinic"); command("change_box all triclinic");
command("dump id0 all atom 1 dump_text_tri_with_units_run0.melt"); command(fmt::format("dump id0 all atom 1 {}", text_file));
command("dump id1 all atom 1 dump_binary_tri_with_units_run0.melt.bin"); command(fmt::format("dump id1 all atom 1 {}", binary_file));
command("dump_modify id0 scale no units yes"); command("dump_modify id0 scale no units yes");
command("dump_modify id1 scale no units yes"); command("dump_modify id1 scale no units yes");
command("run 0"); command("run 0");
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_text_tri_with_units_run0.melt"); ASSERT_FILE_EXISTS(text_file);
ASSERT_FILE_EXISTS("dump_binary_tri_with_units_run0.melt.bin"); ASSERT_FILE_EXISTS(binary_file);
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
std::string cmdline = fmt::format("{} dump_binary_tri_with_units_run0.melt.bin", BINARY2TXT_BINARY); std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
system(cmdline.c_str()); system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_binary_tri_with_units_run0.melt.bin.txt"); ASSERT_FILE_EXISTS(converted_file);
ASSERT_FILE_EQUAL("dump_text_tri_with_units_run0.melt", "dump_binary_tri_with_units_run0.melt.bin.txt"); ASSERT_FILE_EQUAL(text_file, converted_file);
delete_file("dump_text_tri_with_units_run0.melt"); delete_file(text_file);
delete_file("dump_binary_tri_with_units_run0.melt.bin"); delete_file(binary_file);
delete_file("dump_binary_tri_with_units_run0.melt.bin.txt"); delete_file(converted_file);
} }
TEST_F(DumpAtomTest, binary_with_time_run0) TEST_F(DumpAtomTest, binary_with_time_run0)

View File

@ -140,13 +140,13 @@ TEST_F(DumpCustomTest, custom_run0)
TEST_F(DumpCustomTest, binary_run1) TEST_F(DumpCustomTest, binary_run1)
{ {
if(!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_text_run1.melt"; auto text_file = "dump_custom_text_run1.melt";
auto binary_file = "dump_custom_binary_run1.melt.bin"; auto binary_file = "dump_custom_binary_run1.melt.bin";
auto converted_file = fmt::format("{}.txt", binary_file); auto converted_file = fmt::format("{}.txt", binary_file);
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz"; auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
command(fmt::format("dump id0 all custom 1 {} {}", text_file, fields)); command(fmt::format("dump id0 all custom 1 {} {}", text_file, fields));
command(fmt::format("dump id1 all custom 1 {} {}", binary_file, fields)); command(fmt::format("dump id1 all custom 1 {} {}", binary_file, fields));
@ -195,13 +195,13 @@ TEST_F(DumpCustomTest, triclinic_run1)
TEST_F(DumpCustomTest, binary_triclinic_run1) TEST_F(DumpCustomTest, binary_triclinic_run1)
{ {
if(!BINARY2TXT_BINARY) GTEST_SKIP();
auto text_file = "dump_custom_tri_text_run1.melt"; auto text_file = "dump_custom_tri_text_run1.melt";
auto binary_file = "dump_custom_tri_binary_run1.melt.bin"; auto binary_file = "dump_custom_tri_binary_run1.melt.bin";
auto converted_file = fmt::format("{}.txt", binary_file); auto converted_file = fmt::format("{}.txt", binary_file);
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz"; auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
command("change_box all triclinic"); command("change_box all triclinic");
command(fmt::format("dump id0 all custom 1 {} {}", text_file, fields)); command(fmt::format("dump id0 all custom 1 {} {}", text_file, fields));