summaryrefslogtreecommitdiff
path: root/cad/plugins/NanoVision-1/src/Utility/NXStringTokenizerTest.cpp
blob: d9c645fef74daaf745f1a11d9608a7492fbd8084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2008 Nanorex, Inc.  See LICENSE file for details.

#include "NXStringTokenizerTest.h"


CPPUNIT_TEST_SUITE_REGISTRATION(NXStringTokenizerTest);
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(NXStringTokenizerTest, "NXStringTokenizerTestSuite");

/* FUNCTION: setUp */
void NXStringTokenizerTest::setUp() {
}


/* FUNCTION: tearDown */
void NXStringTokenizerTest::tearDown() {
}


/* FUNCTION: tokenization */
void NXStringTokenizerTest::tokenization() {
	std::string inString = "a,b,c";
	Nanorex::NXStringTokenizer tokenizer(inString, ",");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "a");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "b");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "c");
	CPPUNIT_ASSERT(!tokenizer.hasMoreTokens());

	inString = ",a;b,c;";
	tokenizer = Nanorex::NXStringTokenizer(inString, ",;");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "a");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "b");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "c");
	CPPUNIT_ASSERT(!tokenizer.hasMoreTokens());

	inString = ",,a;b;;";
	tokenizer = Nanorex::NXStringTokenizer(inString, ",;");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "a");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "b");
	CPPUNIT_ASSERT(tokenizer.getNextToken() == "");
	CPPUNIT_ASSERT(!tokenizer.hasMoreTokens());
}