Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.4 KiB

  1. // Test String class
  2. #include "headers.hxx"
  3. #include <containers.hpp>
  4. #include <iostream>
  5. HINSTANCE hResourceModuleHandle = 0;
  6. const wchar_t* RUNTIME_NAME = L"coretest";
  7. DWORD DEFAULT_LOGGING_OPTIONS = Burnslib::Log::OUTPUT_TYPICAL;
  8. void
  9. DumpList(const StringList& tokens)
  10. {
  11. for (
  12. StringList::iterator i = tokens.begin();
  13. i != tokens.end();
  14. ++i)
  15. {
  16. AnsiString ansi;
  17. i->convert(ansi);
  18. std::cout << ansi << std::endl;
  19. }
  20. }
  21. void
  22. test1()
  23. {
  24. // use default whitespace delimiter
  25. String s(L"a list of\ttokens \tall in a\t\trow");
  26. StringList tokens;
  27. size_t token_count = s.tokenize(std::back_inserter(tokens));
  28. ASSERT(token_count == tokens.size());
  29. DumpList(tokens);
  30. }
  31. void
  32. test2()
  33. {
  34. // use custom delimiters, end with delimiter
  35. String s(L"mydomain.in-addr.arpa.");
  36. StringList tokens;
  37. size_t token_count = s.tokenize(std::back_inserter(tokens), L".");
  38. ASSERT(token_count == tokens.size());
  39. DumpList(tokens);
  40. }
  41. void
  42. test3()
  43. {
  44. // use custom delimiters
  45. String s(L"mydomain.ipv6.int");
  46. StringList tokens;
  47. size_t token_count = s.tokenize(std::back_inserter(tokens), L".");
  48. ASSERT(token_count == tokens.size());
  49. DumpList(tokens);
  50. }
  51. VOID
  52. _cdecl
  53. main(int, char **)
  54. {
  55. LOG_FUNCTION(main);
  56. test1();
  57. test2();
  58. test3();
  59. }