QMCPACK
test_FileUtility.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2023 QMCPACK developers.
6 //
7 // File developed by: Steven Hahn, hahnse@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Steven Hahn, hahnse@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 
14 #include "OhmmsData/FileUtility.h"
15 
16 #include <string>
17 #include <string_view>
18 
19 TEST_CASE("FileUtility", "[xml]")
20 {
21  std::string empty;
22  REQUIRE(getExtension(empty) == std::string_view());
23 
24  std::string no_extension("this_filename_has_no_extension");
25  REQUIRE(getExtension(no_extension) == std::string_view());
26 
27  std::string single_extension("filename.h5");
28  REQUIRE(getExtension(single_extension) == "h5");
29 
30  std::string multiple_extensions("filename.p001.h5");
31  REQUIRE(getExtension(multiple_extensions) == "h5");
32 }
TEST_CASE("FileUtility", "[xml]")
REQUIRE(std::filesystem::exists(filename))
std::string_view getExtension(const std::string_view str)
Definition: FileUtility.h:19