aboutsummaryrefslogtreecommitdiff
path: root/test/common/str.h
blob: 7b71bd3ecdb44b16ff8b89b0d1197413953113b6 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <cxxtest/TestSuite.h>

#include "stdafx.h"
#include "common/str.h"

class StringTestSuite : public CxxTest::TestSuite 
{
	public:
	void test_isEmpty_clear( void )
	{
		Common::String str("test");
		TS_ASSERT( !str.isEmpty() );
		str.clear();
		TS_ASSERT( str.isEmpty() );
	}

	void test_lastChar( void )
	{
		Common::String str;
		TS_ASSERT_EQUALS( str.lastChar(), '\0' );
		str = "test";
		TS_ASSERT_EQUALS( str.lastChar(), 't' );
		Common::String str2("bar");
		TS_ASSERT_EQUALS( str2.lastChar(), 'r' );
	}

	void test_concat1( void )
	{
		Common::String str("foo");
		Common::String str2("bar");
		str += str2;
		TS_ASSERT_EQUALS( str, "foobar" );
		TS_ASSERT_EQUALS( str2, "bar" );
	}

	void test_concat2( void )
	{
		Common::String str("foo");
		str += "bar";
		TS_ASSERT_EQUALS( str, "foobar" );
	}

	void test_concat3( void )
	{
		Common::String str("foo");
		str += 'X';
		TS_ASSERT_EQUALS( str, "fooX" );
	}

	void test_toLowercase( void )
	{
		Common::String str("Test it, NOW! 42");
		str.toLowercase();
		TS_ASSERT_EQUALS( str, "test it, now! 42" );
	}

	void test_toUppercase( void )
	{
		Common::String str("Test it, NOW! 42");
		str.toUppercase();
		TS_ASSERT_EQUALS( str, "TEST IT, NOW! 42" );
	}
};