Esempio n. 1
0
EString SmtpParser::command()
{
    EString c;
    c.append( letters( 1, 10 ).lower() );
    if ( c == "mail" || c == "rcpt" ) {
        whitespace();
        c.append( " " );
        c.append( letters( 2, 4 ).lower() );
    }
    return c;
}
Esempio n. 2
0
static void		ft_tab(char **tab, char c, char const *s)
{
	int		i;
	int		j;
	int		count;

	i = 0;
	count = 0;
	while (s[count] != '\0' && (skip_char(s, c, count) != -1))
	{
		j = 0;
		count = skip_char(s, c, count);
		tab[i] = (char *)malloc((letters(s, c, count) + 1) * sizeof(char));
		if (tab[i] != NULL)
		{
			while (s[count] != c && s[count] != '\0')
			{
				tab[i][j] = s[count];
				j++;
				count++;
			}
			tab[i][j] = '\0';
			i++;
		}
	}
	tab[i] = NULL;
}
Esempio n. 3
0
int main(int argc, char *argv[]) {
  char *arrayp;
  int *intp;
  printf("input file: %s\n", argv[1]);
  FILE *filep = fopen(argv[1], "r");
  
  if(filep == 0)
    printf("file not found::\n");

  else {
    if(argc == 3){
      // output goes to argv[argc-1]
      printf("output file: %s\n", argv[2]);
      arrayp = cmdLine(3, *argv, filep);
   } 
    else if(argc == 2){
      // output to screen
      arrayp = cmdLine(2, *argv, filep);
    }
    
    intp = letters(intp, arrayp);
    
    int r = 0;
    for(r = 0; r < size; r++){}  // printing returned side effect array
      // printf("%c", arrayp[r]);
    
  }// end if/else
}// end main()
Esempio n. 4
0
SAWYER_EXPORT std::string
generateSequentialName(size_t length) {
    static size_t ncalls = 0;
    size_t sequence = ncalls++;
    std::string letters(length, 'a');
    for (size_t i=0; i<length && sequence; ++i, sequence/=26)
        letters[length-(i+1)] += sequence % 26;
    return letters;
}
Esempio n. 5
0
int
main(int argc, char *argv[])
{
  std::string letters("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  std::string line;
  std::map<char, int> freq;

  //
  for (std::string::iterator letter=letters.begin(); letter!=letters.end(); letter++) {
    freq[*letter] = 0;
  }

  // readlines
  int max_freq=0;
  while(getline(std::cin, line)) {
    for (std::string::iterator it=line.begin(); it!=line.end(); it++) {
      std::map<char, int>::iterator it_freq= freq.find(*it);
      if (it_freq != freq.end()) {
        if (max_freq < ++ it_freq->second) {
          max_freq = it_freq->second;
        }
      }
    }
  }

  // print rows
  for (int row= max_freq; row!=0; row--) {
    // print columns
    std::string blanks;
    for (std::string::iterator letter=letters.begin(); letter!=letters.end(); letter++) {
      if (freq[*letter] >= row) {
        std::cout << blanks << "* ";
        blanks.clear();
      } else {
        blanks.push_back(' ');
        blanks.push_back(' ');
      }
    }
    std::cout << std::endl;
  }

  // print legend
  for (std::string::iterator letter=letters.begin(); letter!=letters.end(); letter++) {
    std::cout << *letter << " ";
  }
  std::cout << std::endl;

  // for (std::map<char, int>::iterator it = freq.begin(); it != freq.end(); it++) {
  //   std::cout << it->first << ": " << it->second << std::endl;
  // }

}
Esempio n. 6
0
static int
gtp_showboard(char *s)
{
  int i, j;
  int symbols[3] = {'.', 'O', 'X'};
  
  gtp_start_response(GTP_SUCCESS);
  gtp_printf("\n");

  letters();
  
  for (i = 0; i < board_size; i++) {
    printf("\n%2d", board_size - i);
    
    for (j = 0; j < board_size; j++)
      printf(" %c", symbols[get_board(i, j)]);

    printf(" %d", board_size - i);
  }
  
  printf("\n");
  letters();
  return gtp_finish_response();
}
Esempio n. 7
0
File: status.cpp Progetto: aox/aox
void Status::parse()
{
    space();
    d->mailbox = mailbox();
    space();
    require( "(" );

    EString l( "Status " );
    if ( d->mailbox ) {
        l.append(  d->mailbox->name().ascii() );
        l.append( ":" );
    }
    bool atEnd = false;
    while ( !atEnd ) {
        EString item = letters( 1, 13 ).lower();
        l.append( " " );
        l.append( item );

        if ( item == "messages" )
            d->messages = true;
        else if ( item == "recent" )
            d->recent = true;
        else if ( item == "uidnext" )
            d->uidnext = true;
        else if ( item == "uidvalidity" )
            d->uidvalidity = true;
        else if ( item == "unseen" )
            d->unseen = true;
        else if ( item == "highestmodseq" )
            d->modseq = true;
        else
            error( Bad, "Unknown STATUS item: " + item );

        if ( nextChar() == ' ' )
            space();
        else
            atEnd = true;
    }

    require( ")" );
    end();
    if ( !ok() )
        return;

    log( l );
    requireRight( d->mailbox, Permissions::Read );
}
Esempio n. 8
0
void		ls_l(t_file *dir, int i, t_stat *st)
{
	t_align	*max_all;

	if (i == 0)
		total_block(dir, st);
	max_all = max(dir, i, st);
	while (dir != NULL)
	{
		if (i == 1 || (!ERR && opt_a(dir) && st->st_mode & S_IXUSR && STAT))
		{
			letters(dir, *(dir->stat), max_all);
			if (S_ISCHR(dir->stat->st_mode) || S_ISBLK(dir->stat->st_mode))
				print_ischr(dir, max_all);
			else
				display_size_right(max_all->size, *(dir->stat));
			date(dir, *(dir->stat), i);
		}
		else if (opt_a(dir))
			err_l(dir->f_name);
		dir = dir->next;
	}
	free(max_all);
}
Esempio n. 9
0
int Count(char* str, int size) {
    int i = 0, sum = 0;
    while (i < size)
        sum += letters(str[i++]);
    return sum;
}
Esempio n. 10
0
int main()
{
	std::cout << __LINE__ << std::endl;
	// default constructor implies empty string
	{
		stdex::static_cstring<20> sv;
		BOOST_TEST(sv.empty());
		BOOST_TEST(sv.size() == 0);
		BOOST_TEST(sv.c_str() == std::string());
	}
	std::cout << __LINE__ << std::endl;
	// default constructor implies empty string
	{
		stdex::static_cstring<20> sv{};
		BOOST_TEST(sv.empty());
		BOOST_TEST(sv.size() == 0);
		BOOST_TEST(sv.c_str() == std::string());
	}
	std::cout << __LINE__ << std::endl;
	// constructor from a NTXS of length > 0
	{
		const char *str = "Hello";
		std::size_t len;
		bool        b = stdex::ntxs::test_and_set_length<20>(str, len);
		BOOST_TEST(b);
		BOOST_TEST_EQ(5, len);
	}
	{
		const char *              str = "Hello";
		std::size_t               len = 5;
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str, len);
		BOOST_TEST(!sv.empty());
		BOOST_TEST_EQ(5, sv.size());
	}
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv{stdex::null_terminated_t{}, str};
		BOOST_TEST(!sv.empty());
		BOOST_TEST_EQ(5, sv.size());
		BOOST_TEST_EQ(stdex::string_view(sv), std::string(str));
		BOOST_TEST_EQ(sv.to_string(), std::string(str));
		BOOST_TEST_EQ(std::string(sv), std::string(str));
	}
	std::cout << __LINE__ << std::endl;
#if 0
	// constructor from nullptr_t must compile fail
	{
		
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, nullptr);
	}
#endif
	std::cout << __LINE__ << std::endl;
	// constructor from a const char* equal to nullptr is UB, don't do it
	// string_view doesn't throws when not valid as it is required to be UB
	if (0)
	{
		try
		{
			const char *              str = nullptr;
			stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
			BOOST_TEST(false);
		}
		catch (...)
		{
		}
	}
	std::cout << __LINE__ << std::endl;
	// construction from c-string literal
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "Hello");
		BOOST_TEST(!sv.empty());
	}
	std::cout << __LINE__ << std::endl;
	// construction from empty c-string literal
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "");
		BOOST_TEST(sv.to_string().empty());
		BOOST_TEST(sv.empty());
		BOOST_TEST(sv.c_str() == std::string());
	}
	std::cout << __LINE__ << std::endl;
	// construction from std::string
	{
		std::string               str("Hello");
		stdex::static_cstring<20> sv(str);
		BOOST_TEST(!sv.empty());
		BOOST_TEST(sv.c_str() == str);
	}
	std::cout << __LINE__ << std::endl;
	// construction from std::string
	{
		std::string               str{"Hello"};
		stdex::static_cstring<20> sv(str);
		BOOST_TEST(!sv.empty());
		BOOST_TEST(sv.c_str() == str);
	}
	std::cout << __LINE__ << std::endl;
	// construction from N char
	{
		stdex::static_cstring<20> sv(stdex::length_tag_t{}, 3, 'X');
		BOOST_TEST(!sv.empty());
		BOOST_TEST(sv.to_string() == "XXX");
	}
	std::cout << __LINE__ << std::endl;
// implicit construction from N char  compile fails
#if 0
	{
		stdex::static_cstring<20> sv(48, 'X');
	}
#endif
	std::cout << __LINE__ << std::endl;
	// implicit construction from a initializer list
	// construction from N char
	{
		stdex::static_cstring<20> sv{48, 'X'};
		BOOST_TEST(!sv.empty());
		BOOST_TEST(sv.to_string() == "0X");
	}
	std::cout << __LINE__ << std::endl;
	{
		stdex::static_cstring<20> sv = {48, 'X'};
		BOOST_TEST(!sv.empty());
		BOOST_TEST(sv.to_string() == "0X");
	}
	std::cout << __LINE__ << std::endl;
	// iteration over the chars using range-based for loop
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		std::ostringstream        os;
		for (auto ch : sv)
			os << ch;
		BOOST_TEST(os.str() == str);
	}
	// iteration over the chars using range-based for loop
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		for (auto &ch : sv)
			ch = 'a';
		BOOST_TEST(sv.to_string() == "aaaaa");
	}
	// operator=

	// assign
	std::cout << __LINE__ << std::endl;
	// Assign n chars
	{
		stdex::static_cstring<20> sv;
		sv.assign(3, 'X');
		BOOST_TEST(sv.to_string() == "XXX");
	}
	std::cout << __LINE__ << std::endl;
	// Assign another string
	{
		stdex::static_cstring<20> sw{stdex::null_terminated_t{}, "Hello"};
		stdex::static_cstring<20> sv;
		sv.assign(sw);
		BOOST_TEST(sv.to_string() == "Hello");
	}
	std::cout << __LINE__ << std::endl;
	// Assign another substring
	{
		stdex::static_cstring<20> sw{stdex::null_terminated_t{}, "Hello"};
		stdex::static_cstring<20> sv;
		sv.assign(sw, 1, 3);
		BOOST_TEST(sv.to_string() == "ell");
	}
	std::cout << __LINE__ << std::endl;
	// Assign another substring over
	{
		stdex::static_cstring<20> sw{stdex::null_terminated_t{}, "Hello"};
		stdex::static_cstring<20> sv;
		sv.assign(sw, 1, 5);
		std::cout << sv.c_str() << " " << sv.size() << std::endl;
		BOOST_TEST(sv.to_string() == "ello");
	}
	std::cout << __LINE__ << std::endl;
	// Assign another substring npos
	{
		stdex::static_cstring<20> sw{stdex::null_terminated_t{}, "Hello"};
		stdex::static_cstring<20> sv;
		sv.assign(sw, 1, stdex::static_cstring<20>::npos);
		std::cout << sv.c_str() << " " << sv.size() << std::endl;
		BOOST_TEST(sv.to_string() == "ello");
	}
	std::cout << __LINE__ << std::endl;
	// Assign another empty substring
	{
		stdex::static_cstring<20> sw{stdex::null_terminated_t{}, "Hello"};
		stdex::static_cstring<20> sv;
		sv.assign(sw, 1, 0);
		std::cout << sv.c_str() << " " << sv.size() << std::endl;
		BOOST_TEST(sv.to_string() == "");
	}
	std::cout << __LINE__ << std::endl;
	// Assign a literal string
	{
		stdex::static_cstring<20> sv;
		sv.assign("Hello");
		BOOST_TEST(sv.to_string() == "Hello");
	}
	std::cout << __LINE__ << std::endl;
	// Assign a const char *
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv;
		sv.assign(str);
		BOOST_TEST(sv.to_string() == "Hello");
	}
	std::cout << __LINE__ << std::endl;
	// Assign a prefix of a const char *
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv;
		sv.assign(str, 3);
		BOOST_TEST(sv.to_string() == "Hel");
	}
	std::cout << __LINE__ << std::endl;
	// Assign a range
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv;
		sv.assign(str + 1, str + 3);
		BOOST_TEST(sv.to_string() == "el");
	}
	std::cout << __LINE__ << std::endl;
	// Assign a range
	{
		stdex::static_cstring<20> sv;
		sv.assign({'e', 'l'});
		BOOST_TEST(sv.to_string() == "el");
	}

	// range based for loop
	std::cout << __LINE__ << std::endl;
	// iteration over the chars using index and size
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		std::ostringstream        os;
		for (std::size_t i = 0, l = sv.size(); i < l; ++i)
			os << sv[i];
		BOOST_TEST(os.str() == str);
	}
	std::cout << __LINE__ << std::endl;
	// iteration over the chars using index and size
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		for (std::size_t i = 0, l = sv.size(); i < l; ++i)
			sv[i] = 'b';
		BOOST_TEST(sv.to_string() == "bbbbb");
	}
	std::cout << __LINE__ << std::endl;
	// at good index read access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(sv.at(0) == 'H');
	}
	std::cout << __LINE__ << std::endl;
	// at good index write access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.at(0) = 'h';
		BOOST_TEST(sv.to_string() == "hello");
	}
	// front/back good index access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(sv.front() == 'H');
		BOOST_TEST(sv.back() == 'o');
	}
	// front/back good index access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.front() = 'h';
		BOOST_TEST(sv.to_string() == "hello");
	}
	// front/back good index access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.back() = 'a';
		BOOST_TEST(sv.to_string() == "Hella");
	}
	// data access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(sv.data() == std::string(str));
	}
	// c_str access
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(sv.c_str() == std::string(str));
	}
	// implicit conversion to string_view
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);
		stdex::string_view        sv{scstr};
		BOOST_TEST(sv.data() == scstr.data());
	}
	// implicit conversion to cstring_view
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);
		stdex::cstring_view       sv{scstr};
		BOOST_TEST(sv.data() == scstr.data());
	}
// implicit conversion to cstr_view
#if defined __clang__ && __cplusplus > 201402L
	// fixme: why this is ambiguous and not the following
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);
		stdex::cstr_view          sv(scstr);
		BOOST_TEST(sv.data() == scstr.data());
	}
#endif
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);
		stdex::cstr_view          sv = scstr;
		BOOST_TEST(sv.data() == scstr.data());
	}
	// to_string
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(sv.to_string() == str);
	}
	// explicit conversion to string
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		BOOST_TEST(std::string(sv) == str);
	}
	// clear()
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.clear();
		BOOST_TEST(sv.to_string() == "");
	}
	// insert
	// ambiguous interface when using 0, which is convertible to size_t and char const* :(
	//         basic_static_cstring &insert(size_type 	 index, size_type count, charT ch)
	//         iterator 			 insert(const_iterator pos, size_type count, charT ch)
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		sv.insert(0ul, 3, 'x');
		BOOST_TEST(sv.to_string() == "xxx0123456");
	}
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		sv.insert(3, 2, 'x');
		BOOST_TEST(sv.to_string() == "012xx3456");
	}
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "01234");
		sv.insert(5, 2, 'x');
		BOOST_TEST(sv.to_string() == "01234xx");
	}
	try
	{

		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "01234");
		sv.insert(6, 2, 'x');
		BOOST_TEST(false);
	}
	catch (stdex::contract_failed &ex)
	{
		stdex::string_view msg = ex.what();
		BOOST_TEST_EQ(msg.substr(0, 28), "JASEL: Pre-condition failure");
	}
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		sv.insert(0ul, "xxx");
		BOOST_TEST(sv.to_string() == "xxx0123456");
	}
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		sv.insert(2, "xxx");
		BOOST_TEST(sv.to_string() == "01xxx23456");
	}
	try
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "012");
		sv.insert(6, "xxx");
		BOOST_TEST(false);
	}
	catch (stdex::contract_failed &ex)
	{
		stdex::string_view msg = ex.what();
		BOOST_TEST_EQ(msg.substr(0, 28), "JASEL: Pre-condition failure");
	}
	{
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		auto                      it = sv.insert(sv.data(), 3, 'x');
		BOOST_TEST(it == sv.data());
		BOOST_TEST(sv.to_string() == "xxx0123456");
	}
	{
		stdex::static_cstring<20> letters(stdex::null_terminated_t{}, "abcdef");
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, "0123456");
		sv.insert(sv.data() + 2, letters.data() + 2, letters.data() + 4);
		BOOST_TEST(sv.to_string() == "01cd23456");
	}

	// erase

	// push_back
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.push_back(' ');
		BOOST_TEST(sv.to_string() == "Hello ");
	}
	// pop_back
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.pop_back();
		BOOST_TEST(sv.to_string() == "Hell");
	}
	// replace

	// resize
	{
		const char *              str = "XXX";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.resize(5, ' ');
		BOOST_TEST(sv.to_string() == "XXX  ");
	}
	// resize
	{
		const char *              str = "XXX";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.resize(2, ' ');
		BOOST_TEST(sv.to_string() == "XX");
	}
	// remove_prefix
	// resize
	{
		const char *              str = "XXX";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.resize(5);
		BOOST_TEST(sv.size() == 5);
		BOOST_TEST(sv[3] == '\0');
		BOOST_TEST(sv[4] == '\0');
		BOOST_TEST(sv[5] == '\0');
		BOOST_TEST(sv.c_str() == std::string("XXX"));
	}
	// resize
	{
		const char *              str = "XXX";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.resize(2);
		BOOST_TEST(sv.to_string() == "XX");
		BOOST_TEST(sv.size() == 2);
	}
	{
		const char *              str = "Hello World";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.remove_prefix(6);
		BOOST_TEST(sv.to_string() == "World");
	}
	// remove_suffix
	{
		const char *              str = "Hello World";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, str);
		sv.remove_suffix(6);
		BOOST_TEST(sv.to_string() == "Hello");
	}
	// swap
	{
		const char *              hello = "Hello";
		const char *              world = "World";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, hello);
		stdex::static_cstring<20> sw(stdex::null_terminated_t{}, world);
		swap(sv, sw);
		BOOST_TEST(sv.to_string() == "World");
	}

	// compare different
	{
		const char *              hello = "Hello";
		const char *              world = "World";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, hello);
		stdex::static_cstring<20> sw(stdex::null_terminated_t{}, world);
		BOOST_TEST(sv.compare(sw) < 0);
		BOOST_TEST(sw.compare(sv) > 0);
	}
	// compare equals
	{
		const char *              hello = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, hello);
		stdex::static_cstring<20> sw(stdex::null_terminated_t{}, hello);
		BOOST_TEST(sv.compare(sw) == 0);
	}
	// compare equals with const char *
	{
		const char *              hello = "Hello";
		stdex::static_cstring<20> sv(stdex::null_terminated_t{}, hello);
		BOOST_TEST(sv.compare("Hello") == 0);
	}
	// test for all the string_view specific functions go here
	{
		auto str = stdex::to_static_cstring<10>(100);
		BOOST_TEST(str.to_string() == std::string("100"));
	}
	{
		stdex::static_cstring<20> str(stdex::null_terminated_t{}, "100");
		int                       value;
		auto                      result = stdex::from_chars(str.c_str(), str.c_str() + str.size(), value, 10);
		BOOST_TEST(result.ec == std::errc{});
		auto i = stdex::sto<int>(str);
		BOOST_TEST_EQ(i, 100);
		//BOOST_TEST_EQ(stdex::sto<int>(str), 100);
		//BOOST_TEST_EQ(stdex::stoi(str), 100);
	}
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);

		auto sp = scstr.borrow(10);
		BOOST_TEST(sp.size() == 10);
		BOOST_TEST(sp.data() == scstr.end());
		scstr.give_back(sp);
		BOOST_TEST(scstr.size() == 15);
	}
	{
		const char *              str = "Hello";
		stdex::static_cstring<20> scstr(stdex::null_terminated_t{}, str);

		auto sp = scstr.borrow_all(15);
		BOOST_TEST(sp.size() == 15);
		BOOST_TEST(sp.data() == scstr.data());
		scstr.give_back_all(sp);
		BOOST_TEST(scstr.size() == 15);
	}
	return ::boost::report_errors();
}
Esempio n. 11
0
  Diamond::Lines Diamond::lines(int amount)
  {
    return copy_range<Lines>(combine(spaces_before(amount),
				     letters(amount),
				     spaces_after(amount)) | transformed(impl::concat));
  }