Add UNITS information to dump atom binary format

This commit is contained in:
Richard Berger
2020-08-13 10:49:03 -04:00
parent b27d63059c
commit 6d825dcb6b
3 changed files with 121 additions and 4 deletions

View File

@ -270,6 +270,61 @@ TEST_F(DumpAtomTest, with_units_run1)
delete_file("dump_with_units_run1.melt");
}
TEST_F(DumpAtomTest, binary_with_units_run0)
{
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command("dump id0 all atom 1 dump_text_with_units_run0.melt");
command("dump id1 all atom 1 dump_binary_with_units_run0.melt.bin");
command("dump_modify id0 scale no units yes");
command("dump_modify id1 scale no units yes");
command("run 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_text_with_units_run0.melt");
ASSERT_FILE_EXISTS("dump_binary_with_units_run0.melt.bin");
if (!verbose) ::testing::internal::CaptureStdout();
std::string cmdline = fmt::format("{} dump_binary_with_units_run0.melt.bin", BINARY2TXT_BINARY);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_binary_with_units_run0.melt.bin.txt");
ASSERT_FILE_EQUAL("dump_text_with_units_run0.melt", "dump_binary_with_units_run0.melt.bin.txt");
delete_file("dump_text_with_units_run0.melt");
delete_file("dump_binary_with_units_run0.melt.bin");
delete_file("dump_binary_with_units_run0.melt.bin.txt");
}
TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
{
if(!BINARY2TXT_BINARY) GTEST_SKIP();
if (!verbose) ::testing::internal::CaptureStdout();
command("change_box all triclinic");
command("dump id0 all atom 1 dump_text_tri_with_units_run0.melt");
command("dump id1 all atom 1 dump_binary_tri_with_units_run0.melt.bin");
command("dump_modify id0 scale no units yes");
command("dump_modify id1 scale no units yes");
command("run 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_text_tri_with_units_run0.melt");
ASSERT_FILE_EXISTS("dump_binary_tri_with_units_run0.melt.bin");
if (!verbose) ::testing::internal::CaptureStdout();
std::string cmdline = fmt::format("{} dump_binary_tri_with_units_run0.melt.bin", BINARY2TXT_BINARY);
system(cmdline.c_str());
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_binary_tri_with_units_run0.melt.bin.txt");
ASSERT_FILE_EQUAL("dump_text_tri_with_units_run0.melt", "dump_binary_tri_with_units_run0.melt.bin.txt");
delete_file("dump_text_tri_with_units_run0.melt");
delete_file("dump_binary_tri_with_units_run0.melt.bin");
delete_file("dump_binary_tri_with_units_run0.melt.bin.txt");
}
TEST_F(DumpAtomTest, no_buffer_with_scale_and_image_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();
@ -307,6 +362,28 @@ TEST_F(DumpAtomTest, tricilinic_run0)
delete_file("dump_triclinic_run0.melt");
}
TEST_F(DumpAtomTest, tricilinic_with_units_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();
command("change_box all triclinic");
command("dump id all atom 1 dump_triclinic_with_units_run0.melt");
command("dump_modify id units yes");
command("run 0");
if (!verbose) ::testing::internal::GetCapturedStdout();
ASSERT_FILE_EXISTS("dump_triclinic_with_units_run0.melt");
auto lines = read_lines("dump_triclinic_with_units_run0.melt");
ASSERT_STREQ(lines[0].c_str(), "ITEM: UNITS");
ASSERT_STREQ(lines[1].c_str(), "lj");
ASSERT_STREQ(lines[6].c_str(), "ITEM: BOX BOUNDS xy xz yz pp pp pp");
ASSERT_EQ(utils::split_words(lines[7]).size(), 3);
ASSERT_EQ(lines.size(), 43);
delete_file("dump_triclinic_with_units_run0.melt");
}
TEST_F(DumpAtomTest, triclinic_with_image_run0)
{
if (!verbose) ::testing::internal::CaptureStdout();