QMCPACK
test_string_utils.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) 2022 QMCPACK developers.
6 //
7 // File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
8 //
9 // File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 #include "string_utils.h"
14 
15 /** \file
16  */
17 namespace qmcplusplus
18 {
19 
20 TEST_CASE("string_utils_streamToVec", "[utilities]")
21 {
22  { // empty string
23  std::string test_string("");
24  auto str_vec = convertStrToVec<std::string>(test_string);
25  REQUIRE(str_vec.size() == 0);
26  }
27 
28  { // whitespace string
29  std::string test_string(" ");
30  auto str_vec = convertStrToVec<std::string>(test_string);
31  REQUIRE(str_vec.size() == 0);
32  }
33 
34  {
35  std::string test_string("abc def 123");
36  auto str_vec = convertStrToVec<std::string>(test_string);
37  REQUIRE(str_vec.size() == 3);
38  CHECK(str_vec[0] == "abc");
39  CHECK(str_vec[1] == "def");
40  CHECK(str_vec[2] == "123");
41 
42  // won't work with int
43  CHECK_THROWS_WITH(convertStrToVec<int>(test_string),
44  Catch::Matchers::Contains("Error parsing string 'abc def 123' for type (type_info::name) i."));
45  }
46 }
47 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
REQUIRE(std::filesystem::exists(filename))
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))