string_manip_tests.cpp File Reference

#include <stdlib.h>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <utility>
#include "string_manip.h"
Include dependency graph for string_manip_tests.cpp:

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 []

Detailed Description

Remarks:
Copyright 2003 OProfile authors
Read the file COPYING
Author:
John Levon
Philippe Elie

Definition in file string_manip_tests.cpp.


Define Documentation

#define MAKE_PAIR ( a,
 )     make_pair(string(a), b)
#define MAKE_PAIR ( a,
 )     make_pair(string(a), string(b))

Function Documentation

template<typename Input , typename Output , typename Result >
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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( void   ) 
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

input_output<char const*, char const*> expect_erase[] [static]
Initial value:
{
    { "", "" },
    { ";;;", "" },
    { "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]
Initial value:
{
    { 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]
Initial value:
{
    { "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]
Initial value:
{
    { 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]
Initial value:
{
#define MAKE_PAIR(a, b)  
    { "abcd", MAKE_PAIR("abc", true) },
    { "abcd", MAKE_PAIR("ac", false) },
    { "babcd", MAKE_PAIR("abc", false) },
    
    


    { 0, MAKE_PAIR("", true) }

}

Definition at line 90 of file string_manip_tests.cpp.

input_output<char const *, char const *> expect_ltrim[] [static]
Initial value:
{
    { "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]
Initial value:
{
    { "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]
Initial value:
{
    { "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]
Initial value:
{
#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]
Initial value:
{
    { "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().


Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1