32 const int precision = 6;
43 const int precision = 4;
57 EXPECT_EQ(
TrimWhitespace(
" \t\n abc cde\n"), std::string(
"abc cde"));
134 EXPECT_THROW(
SplitString(
"",
""), std::runtime_error);
135 EXPECT_EQ(
SplitString(
"",
" "), toVector<std::string>());
136 EXPECT_EQ(
SplitString(
"",
","), toVector<std::string>());
137 EXPECT_EQ(
SplitString(
" ",
" "), toVector<std::string>(
"",
""));
138 EXPECT_EQ(
SplitString(
"a",
" "), toVector<std::string>(
"a"));
139 EXPECT_EQ(
SplitString(
"a ",
" "), toVector<std::string>(
"a",
""));
141 EXPECT_EQ(
SplitString(
"a b",
" "), toVector<std::string>(
"a",
"b"));
142 EXPECT_EQ(
SplitString(
"a b",
" "), toVector<std::string>(
"a",
"",
"b"));
144 EXPECT_EQ(
SplitString(
"a",
"-"), toVector<std::string>(
"a"));
146 EXPECT_EQ(
SplitString(
"aa",
"a"), toVector<std::string>(
"",
"",
""));
148 EXPECT_EQ(
SplitString(
"a,b",
","), toVector<std::string>(
"a",
"b"));
149 EXPECT_EQ(
SplitString(
"a, b",
","), toVector<std::string>(
"a",
" b"));
151 EXPECT_EQ(
SplitString(
"a,b,",
","), toVector<std::string>(
"a",
"b",
""));
152 EXPECT_EQ(
SplitString(
",a,b,",
","), toVector<std::string>(
"",
"a",
"b",
""));
153 EXPECT_EQ(
SplitString(
"aabbcc",
"bb"), toVector<std::string>(
"aa",
"cc"));
154 EXPECT_EQ(
SplitString(
"aabbcc",
"bb"), toVector<std::string>(
"aa",
"cc"));
162 std::vector<double> data;
MVVM_MODEL_EXPORT std::string ScientificDoubleToString(double input, int precision=6)
Returns string representation of scientific double.
MVVM_MODEL_EXPORT std::string RemoveRepeatedSpaces(std::string str)
Removes repeating spaces for a string.
MVVM_MODEL_EXPORT std::vector< double > ParseSpaceSeparatedDoubles(const std::string &str)
Parses string for double values and returns result as a vector.
MVVM_MODEL_EXPORT std::string TrimWhitespace(const std::string &str)
Returns string after trimming whitespace surrounding, including tabs and carriage returns.
MVVM_MODEL_EXPORT std::string DoubleToString(double input, int precision=12)
Returns string representation of double with given precision.
MVVM_MODEL_EXPORT std::vector< std::string > SplitString(const std::string &str, const std::string &delimeter)
Split string on substring using given delimeter. Reproduces Python's str.split() behavior.
MVVM_MODEL_EXPORT std::optional< int > StringToInteger(const std::string &str)
Converts string to integer.
MVVM_MODEL_EXPORT std::optional< double > StringToDouble(const std::string &str)
Converts string to double value using classc locale and returns it in the form of optional.
materialitems.h Collection of materials to populate MaterialModel.
Various common utils for unit tests.
TEST_F(StringUtilsTest, ScientificDoubleToString)