OpenMS
Loading...
Searching...
No Matches
OpenMS::Internal::ClassTest::detail Namespace Reference

Concepts

concept  Streamable
 

Functions

void trim (std::string &s)
 Remove leading and trailing whitespace (' ', '\t', '\n', '\r'), like StringUtils::trim.
 
std::vector< std::string > split (const std::string &s, char splitter)
 
std::string join (const std::vector< std::string > &v, const char *sep)
 Join with a separator (display purposes only).
 
template<typename T >
void appendNumeric (T value, std::string &target, int precision, bool fixed_format)
 
Stringification for TEST_EQUAL(std::string, x). Mirrors the

StringUtils::toStr overloads, so TEST_EQUAL(some_string, 114) compares against "114" and doubles keep full precision.

std::string toString (const std::string &s)
 
std::string toString (std::string_view sv)
 
std::string toString (const char *s)
 
std::string toString (char c)
 
template<typename T >
std::string toString (const T &v)
 
template<typename T >
void printValue (std::ostream &os, const T &v)
 
std::filesystem::path to_path (const std::string &s)
 

Function Documentation

◆ appendNumeric()

template<typename T >
void appendNumeric ( T  value,
std::string &  target,
int  precision,
bool  fixed_format 
)
inline

Append a double/float/long double via std::to_chars. VERBATIM copy of appendNumeric in StringUtils.cpp – must format exactly like StringUtils::toStr(); keep in sync, do not "improve". NaN -> "NaN", inf -> "inf"/"-inf"; trailing zeros trimmed, one digit kept after '.'.

Referenced by toString().

◆ join()

std::string join ( const std::vector< std::string > &  v,
const char *  sep 
)
inline

Join with a separator (display purposes only).

◆ printValue()

template<typename T >
void printValue ( std::ostream &  os,
const T &  v 
)

Print a value in a TEST_EQUAL/TEST_NOT_EQUAL failure report: directly if streamable; ranges as "[e1, e2, ...]" (like ListUtilsIO.h); else a placeholder.

References OpenMS::C, first, and toString().

Referenced by OpenMS::Internal::ClassTest::testEqual(), and OpenMS::Internal::ClassTest::testNotEqual().

◆ split()

std::vector< std::string > split ( const std::string &  s,
char  splitter 
)
inline

Split on a single character. Mirrors ListUtils::create<std::string>(s, splitter): an empty input gives an empty result; otherwise empty fields are kept and fields are NOT trimmed.

◆ to_path()

std::filesystem::path to_path ( const std::string &  s)
inline

UTF-8 std::string -> std::filesystem::path. Copy of OpenMS::to_path (OpenMS/SYSTEM/PathUtils.h): on Windows construct from u8string (not the current code page), falling back to the native page for non-UTF-8 bytes.

◆ toString() [1/5]

std::string toString ( char  c)
inline

◆ toString() [2/5]

std::string toString ( const char *  s)
inline

◆ toString() [3/5]

std::string toString ( const std::string &  s)
inline

◆ toString() [4/5]

template<typename T >
std::string toString ( const T &  v)
inline

References appendNumeric().

◆ toString() [5/5]

std::string toString ( std::string_view  sv)
inline

◆ trim()

void trim ( std::string &  s)
inline

Remove leading and trailing whitespace (' ', '\t', '\n', '\r'), like StringUtils::trim.