expose guesspath function and add unit test

This commit is contained in:
Axel Kohlmeyer
2020-07-02 09:13:57 -04:00
parent 84ee52a6e5
commit c3fe0e77c2
3 changed files with 32 additions and 9 deletions

View File

@ -22,6 +22,7 @@
using namespace LAMMPS_NS;
using ::testing::Eq;
using ::testing::EndsWith;
TEST(Utils, trim_comment)
{
@ -277,6 +278,20 @@ TEST(Utils, strmatch_opt_range)
ASSERT_TRUE(utils::strmatch("rigid", "^[0-9]*[p-s]igid"));
}
TEST(Utils, guesspath)
{
char buf[128];
FILE *fp = fopen("test_guesspath.txt","w");
#if defined(__linux__)
const char *path = utils::guesspath(buf,sizeof(buf),fp);
ASSERT_THAT(path,EndsWith("test_guesspath.txt"));
#else
const char *path = utils::guesspath(buf,sizeof(buf),fp);
ASSERT_THAT(path,EndsWith("(unknown)"));
#endif
fclose(fp);
}
TEST(Utils, path_join)
{
#if defined(_WIN32)