#include <stdlib.h>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <utility>
#include "string_manip.h"
Go to the source code of this file.
Data Structures | |
struct | input_output< Input, Output > |
Defines | |
#define | MAKE_PAIR(a, b) make_pair(string(a), string(b)) |
#define | MAKE_PAIR(a, b) make_pair(string(a), b) |
Functions | |
template<typename Input , typename Output , typename Result > | |
static void | check_result (char const *fct_name, Input const &input, Output const &output, Result const &result) |
static void | erase_to_last_of_tests () |
static void | split_tests () |
static void | is_prefix_tests () |
static void | separate_token_tests () |
static void | rtrim_tests () |
static void | ltrim_tests () |
static void | trim_tests () |
static void | format_percent_tests () |
static void | tostr_tests () |
static void | touint_tests () |
static void | tobool_tests () |
int | main () |
Variables | |
static input_output< char const *, char const * > | expect_erase [] |
static input_output< char const *, pair< string, string > > | expect_split [] |
static input_output< char const *, pair< string, bool > > | expect_is_prefix [] |
static const size_t | max_token = 8 |
static input_output< char const *, char const *[max_token]> | expect_separate_token [] |
static input_output< char const *, char const * > | expect_rtrim [] |
static input_output< char const *, char const * > | expect_ltrim [] |
static input_output< char const *, char const * > | expect_trim [] |
static input_output< double, char const * > | expect_format_percent [] |
static input_output< unsigned int, char const * > | expect_from_str_to_uint [] |
static input_output< char const *, bool > | expect_from_str_to_bool [] |
Definition in file string_manip_tests.cpp.
#define MAKE_PAIR | ( | a, | |||
b | ) | make_pair(string(a), b) |
#define MAKE_PAIR | ( | a, | |||
b | ) | make_pair(string(a), string(b)) |
static void check_result | ( | char const * | fct_name, | |
Input const & | input, | |||
Output const & | output, | |||
Result const & | result | |||
) | [inline, static] |
Definition at line 30 of file string_manip_tests.cpp.
Referenced by erase_to_last_of_tests(), format_percent_tests(), ltrim_tests(), rtrim_tests(), split_tests(), tobool_tests(), tostr_tests(), touint_tests(), and trim_tests().
static void erase_to_last_of_tests | ( | ) | [static] |
Definition at line 53 of file string_manip_tests.cpp.
References check_result(), erase_to_last_of(), input_output< Input, Output >::input, and input_output< Input, Output >::output.
Referenced by main().
static void format_percent_tests | ( | ) | [static] |
Definition at line 249 of file string_manip_tests.cpp.
References check_result(), format_percent(), input_output< Input, Output >::input, input_output< Input, Output >::output, percent_fract_width, and percent_int_width.
Referenced by main().
static void is_prefix_tests | ( | ) | [static] |
Definition at line 104 of file string_manip_tests.cpp.
References input_output< Input, Output >::input, is_prefix(), and input_output< Input, Output >::output.
Referenced by main().
static void ltrim_tests | ( | ) | [static] |
Definition at line 205 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, ltrim(), and input_output< Input, Output >::output.
Referenced by main().
int main | ( | void | ) |
Definition at line 311 of file string_manip_tests.cpp.
References erase_to_last_of_tests(), format_percent_tests(), is_prefix_tests(), ltrim_tests(), rtrim_tests(), separate_token_tests(), split_tests(), tobool_tests(), tostr_tests(), touint_tests(), and trim_tests().
static void rtrim_tests | ( | ) | [static] |
Definition at line 183 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, input_output< Input, Output >::output, and rtrim().
Referenced by main().
static void separate_token_tests | ( | ) | [static] |
Definition at line 136 of file string_manip_tests.cpp.
References input_output< Input, Output >::input, max_token, input_output< Input, Output >::output, and separate_token().
Referenced by main().
static void split_tests | ( | ) | [static] |
Definition at line 79 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, input_output< Input, Output >::output, and split().
Referenced by main().
static void tobool_tests | ( | ) | [static] |
Definition at line 299 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, op_lexical_cast(), and input_output< Input, Output >::output.
Referenced by main().
static void tostr_tests | ( | ) | [static] |
Definition at line 269 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, op_lexical_cast(), and input_output< Input, Output >::output.
Referenced by main().
static void touint_tests | ( | ) | [static] |
Definition at line 279 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, op_lexical_cast(), and input_output< Input, Output >::output.
Referenced by main().
static void trim_tests | ( | ) | [static] |
Definition at line 227 of file string_manip_tests.cpp.
References check_result(), input_output< Input, Output >::input, input_output< Input, Output >::output, and trim().
Referenced by main().
input_output<char const*, char const*> expect_erase[] [static] |
{ { "", "" }, { ";;;", "" }, { "ab;;;cd", "cd" }, { ";;;cd", "cd" }, { "ab;;;", "" }, { 0, 0 } }
Definition at line 43 of file string_manip_tests.cpp.
input_output<double, char const *> expect_format_percent[] [static] |
{ { 2.2, " 2.2000" }, { 0, " 0" }, { 100.00, "100.000" }, { 99.99999, "100.000" }, { 0.00000344, "3.4e-06" }, { -1.0, 0 } }
Definition at line 237 of file string_manip_tests.cpp.
input_output<char const*, bool> expect_from_str_to_bool[] [static] |
{ { "0", false }, { "1", true }, { 0, 0 } }
Definition at line 292 of file string_manip_tests.cpp.
input_output<unsigned int, char const *> expect_from_str_to_uint[] [static] |
{ { 123, "123" }, { 33, "33" }, { 0, "0" }, { 0, 0 } }
Definition at line 261 of file string_manip_tests.cpp.
input_output<char const *, pair<string, bool> > expect_is_prefix[] [static] |
input_output<char const *, char const *> expect_ltrim[] [static] |
{ { "abc", "abc" }, { "abc ", "abc " }, { " abc ", "abc " }, { "\t \tabc ", "abc " }, { " ", "" }, { "\t \t", "" }, { "", "" }, { 0, 0 } }
Definition at line 193 of file string_manip_tests.cpp.
input_output<char const *, char const *> expect_rtrim[] [static] |
{ { "abc", "abc" }, { "abc ", "abc" }, { " abc ", " abc" }, { " abc \t \t", " abc" }, { " ", "" }, { "\t \t", "" }, { "", "" }, { 0, 0 } }
Definition at line 171 of file string_manip_tests.cpp.
input_output<char const *, char const *[max_token]> expect_separate_token[] [static] |
{ { "aa", { "aa" } }, { "a\\c", { "a\\c" } }, { "a\\\\c", { "a\\\\c" } }, { "a\\\\c\\", { "a\\\\c\\" } }, { "ab;cd;ef;gh", { "ab", "cd", "ef", "gh" } }, { "ab\\;cd", { "ab;cd" } }, { "a;a", { "a", "a" } }, { ";a", { "", "a" } }, { ";", { "", "" } }, { ";;", { "", "", "" } }, { 0, { 0, } } }
Definition at line 120 of file string_manip_tests.cpp.
input_output<char const *, pair<string, string> > expect_split[] [static] |
{ #define MAKE_PAIR(a, b) { "ab;cd", MAKE_PAIR("ab", "cd") }, { ";cd", MAKE_PAIR("", "cd") }, { "ab;", MAKE_PAIR("ab", "") }, { "b;d", MAKE_PAIR("b", "d") }, { ";d", MAKE_PAIR("", "d") }, { "a;", MAKE_PAIR("a", "") }, { ";", MAKE_PAIR("", "") }, { "", MAKE_PAIR("", "") }, { 0, MAKE_PAIR("", "") } }
Definition at line 64 of file string_manip_tests.cpp.
input_output<char const *, char const *> expect_trim[] [static] |
{ { "abc", "abc" }, { "abc ", "abc" }, { " abc ", "abc" }, { "\t \tabc \t", "abc" }, { " ", "" }, { "\t \t", "" }, { "", "" }, { 0, 0 } }
Definition at line 215 of file string_manip_tests.cpp.
const size_t max_token = 8 [static] |
Definition at line 119 of file string_manip_tests.cpp.
Referenced by separate_token_tests().