Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Character.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include <iostream>
18
19 #include <stdlib.h>
20 #include <dali/dali.h>
21 #include <dali-test-suite-utils.h>
22
23 using namespace Dali;
24
25 void utc_dali_character_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void utc_dali_character_cleanup(void)
31 {
32   test_return_value = TET_PASS;
33 }
34
35 int UtcDaliCharacterCopyConstructor(void)
36 {
37   tet_infoline("UtcDaliCharacterCopyConstructor ");
38   TestApplication application;
39
40   Text text( std::string("12") );
41
42   Character c1 = text[0];
43   Character c2 = text[1];
44
45   Character c3( c1 );
46   Character c4 = c2;
47
48   DALI_TEST_CHECK( (c1==c3) && (c2==c4) );
49   END_TEST;
50 }
51
52 int UtcDaliCharacterComparissonOperators(void)
53 {
54   tet_infoline("UtcDaliCharacterComparissonOperators ");
55   TestApplication application;
56
57   Text text( std::string("12") );
58
59   Character c1 = text[0];
60   Character c2 = text[1];
61
62   Character c3( c1 );
63   Character c4 = c2;
64
65   DALI_TEST_CHECK( (c1==c3) && (c2==c4) && (c1!=c2) && (c1!=c4) );
66   END_TEST;
67 }
68
69 int UtcDaliCharacterAssignmentOperator(void)
70 {
71   tet_infoline("UtcDaliCharacterAssignmentOperator ");
72   TestApplication application;
73
74   Text text( std::string("12") );
75   Character c1 = text[0];
76   Character c2 = text[1];
77   c1 = c2; //assign
78   DALI_TEST_CHECK( c1 == c1);
79
80   // this should do nothing
81   c1 = c1;
82   DALI_TEST_CHECK(  c1 == c2);
83
84   END_TEST;
85 }
86
87 int UtcDaliCharacterIsLeftToRight(void)
88 {
89   tet_infoline("UtcDaliCharacterIsLeftToRight ");
90   TestApplication application;
91
92   Text text( std::string("12בא") );
93
94   Character c1 = text[0];
95   Character c2 = text[1];
96   Character c3 = text[2];
97   Character c4 = text[3];
98
99   DALI_TEST_CHECK( c1.GetCharacterDirection() != Character::RightToLeft &&
100                    c2.GetCharacterDirection() != Character::RightToLeft &&
101                    c3.GetCharacterDirection() == Character::RightToLeft &&
102                    c4.GetCharacterDirection() == Character::RightToLeft );
103   END_TEST;
104 }
105
106 int UtcDaliGetCharacterDirection(void)
107 {
108   tet_infoline("UtcDaliGetCharacterDirection ");
109   TestApplication application;
110
111   Text text( std::string("Aבא ") );
112
113   Character c1 = text[0];
114   Character c2 = text[1];
115   Character c3 = text[2];
116   Character c4 = text[3];
117
118   DALI_TEST_EQUALS( c1.GetCharacterDirection(), Character::LeftToRight, TEST_LOCATION );
119   DALI_TEST_EQUALS( c2.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
120   DALI_TEST_EQUALS( c3.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION );
121   DALI_TEST_EQUALS( c4.GetCharacterDirection(), Character::Neutral, TEST_LOCATION );
122   END_TEST;
123 }
124
125 int UtcDaliCharacterIsWhiteSpace(void)
126 {
127   tet_infoline("UtcDaliCharacterIsWhiteSpace ");
128   TestApplication application;
129
130   Text text( std::string("ab c\n\tdef") );
131
132   DALI_TEST_CHECK(!text[0].IsWhiteSpace()); // 'a'
133   DALI_TEST_CHECK(!text[1].IsWhiteSpace()); // 'b'
134   DALI_TEST_CHECK(text[2].IsWhiteSpace());  // ' '
135   DALI_TEST_CHECK(!text[3].IsWhiteSpace()); // 'c'
136   DALI_TEST_CHECK(text[4].IsWhiteSpace());  // '\n'
137   DALI_TEST_CHECK(text[5].IsWhiteSpace());  // '\t'
138   DALI_TEST_CHECK(!text[6].IsWhiteSpace()); // 'd'
139   DALI_TEST_CHECK(!text[7].IsWhiteSpace()); // 'e'
140   DALI_TEST_CHECK(!text[8].IsWhiteSpace()); // 'f'
141   END_TEST;
142 }
143
144 int UtcDaliCharacterIsNewLine(void)
145 {
146   tet_infoline("UtcDaliCharacterIsWhiteSpace ");
147   TestApplication application;
148
149   Text text( std::string("ab c\n\tdef") );
150
151   DALI_TEST_CHECK(!text[0].IsNewLine()); // 'a'
152   DALI_TEST_CHECK(!text[1].IsNewLine()); // 'b'
153   DALI_TEST_CHECK(!text[2].IsNewLine()); // ' '
154   DALI_TEST_CHECK(!text[3].IsNewLine()); // 'c'
155   DALI_TEST_CHECK( text[4].IsNewLine()); // '\n'
156   DALI_TEST_CHECK(!text[5].IsNewLine()); // '\t'
157   DALI_TEST_CHECK(!text[6].IsNewLine()); // 'd'
158   DALI_TEST_CHECK(!text[7].IsNewLine()); // 'e'
159   DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f'
160   END_TEST;
161 }