File: tokenize.cpp

package info (click to toggle)
yrmcds 1.1.9-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 940 kB
  • sloc: cpp: 11,149; sh: 148; makefile: 117
file content (17 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <cybozu/test.hpp>
#include <cybozu/util.hpp>

AUTOTEST(tokenize) {
    cybozu_assert(cybozu::tokenize("", ' ').empty());
    cybozu_assert(cybozu::tokenize(" ", ' ').empty());
    cybozu_assert(cybozu::tokenize(" a", ' ') ==
                  std::vector<std::string>{"a"});
    cybozu_assert(cybozu::tokenize("a ", ' ') ==
                  std::vector<std::string>{"a"});
    cybozu_assert(cybozu::tokenize(" abc  def ", ' ') ==
                  std::vector<std::string>{"abc", "def"});
    cybozu_assert(cybozu::tokenize(" abc  def g", ' ') ==
                  std::vector<std::string>{"abc", "def", "g"});
    cybozu_assert(cybozu::tokenize("0123", ' ') ==
                  std::vector<std::string>{"0123"});
}