Update contrib.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\locale\t_names.cpp
16 // Test Date, Time and Currency Symbol locale settings.
18 // TDayName,TDayNameAbb,TMonthName, TMonthNameAbb, TDateSuffix, TAmPmName,
21 // - Construct and set the full, abbreviated text name for a day of the week,
22 // month and check it is as specified.
23 // - Construct and set date suffix text for a specific day in the month and
24 // test that constructor, TDateSuffix::Set panics when invalid parameters
26 // - Construct and assign current locale's text identifying time before noon,
27 // after noon and check it is as expected.
28 // - Assign the current locale's currency symbol with different text and check
30 // Platforms/Drives/Compatibility:
32 // Assumptions/Requirement/Pre-requisites:
33 // Failures and causes:
34 // Base Port information:
41 // Solve compilation problem caused by non-English locale
42 #pragma setlocale("english")
45 LOCAL_D RTest test(_L("T_NAMES"));
49 test.Start(_L("TDayName"));
51 test(name1.Compare(_L("Monday"))==KErrNone);
52 TDayName name2(ESunday);
53 test(name2.Compare(_L("Sunday"))==KErrNone);
54 name1.Set(EWednesday);
55 test(name1.Compare(_L("Wednesday"))==KErrNone);
60 test.Next(_L("TDayNameAbb"));
62 test(name1.Compare(_L("Mon"))==KErrNone);
63 TDayNameAbb name2(ETuesday);
64 test(name2.Compare(_L("Tue"))==KErrNone);
66 test(name1.Compare(_L("Sat"))==KErrNone);
71 test.Next(_L("TMonthName"));
73 test(name1.Compare(_L("January"))==KErrNone);
74 TMonthName name2(EDecember);
75 test(name2.Compare(_L("December"))==KErrNone);
77 test(name1.Compare(_L("March"))==KErrNone);
80 void TestMonthNameAbb()
82 test.Next(_L("TMonthNameAbb"));
84 test(name1.Compare(_L("Jan"))==KErrNone);
85 TMonthNameAbb name2(EFebruary);
86 test(name2.Compare(_L("Feb"))==KErrNone);
88 test(name1.Compare(_L("Nov"))==KErrNone);
91 TInt TestThread1(TAny* Ptr)
93 // Used in TestDateSuffix() to test the constructor panics when silly parameters are passed
96 TDateSuffix ds((TInt) Ptr);
101 TInt TestThread2(TAny* Ptr)
103 // Used in TestDateSuffix() to test TDateSuffix::Set panics when silly parameters are passed
107 suff.Set((TInt) Ptr);
111 void TestDateSuffix()
113 test.Next(_L("TDateSuffix"));
115 test.Start(_L("Simple creation and assignment"));
117 test(suff1.Compare(_L("st"))==KErrNone);
118 TDateSuffix suff2(1);
119 test(suff2.Compare(_L("nd"))==KErrNone);
121 test(suff1.Compare(_L("rd"))==KErrNone);
123 test.Next(_L("Constructor in a thread"));
126 thread.Create(_L("Test Thread"),TestThread1,KDefaultStackSize,0x100,0x200,(TAny*)0);
129 User::WaitForRequest(stat);
130 test(thread.ExitType()==EExitKill);
131 CLOSE_AND_WAIT(thread);
133 test.Next(_L("Constructor panics for -1"));
134 thread.Create(_L("Test Thread"),TestThread1,KDefaultStackSize,0x100,0x200,(TAny*)-1);
136 // don't want just in time debugging as we trap panics
137 TBool justInTime=User::JustInTime();
138 User::SetJustInTime(EFalse);
140 User::WaitForRequest(stat);
141 User::SetJustInTime(justInTime);
142 test(thread.ExitType()==EExitPanic);
143 CLOSE_AND_WAIT(thread);
145 test.Next(_L("Constructor panics for KMaxSuffices"));
146 thread.Create(_L("Test Thread"),TestThread1,KDefaultStackSize,0x100,0x200,(TAny*)KMaxSuffixes);
148 User::SetJustInTime(EFalse);
150 User::WaitForRequest(stat);
151 User::SetJustInTime(justInTime);
152 test(thread.ExitType()==EExitPanic);
153 CLOSE_AND_WAIT(thread);
155 test.Next(_L("Set in a thread"));
156 thread.Create(_L("Test Thread"),TestThread2,KDefaultStackSize,0x100,0x200,(TAny*)0);
159 User::WaitForRequest(stat);
160 test(thread.ExitType()==EExitKill);
161 CLOSE_AND_WAIT(thread);
163 test.Next(_L("Set panics for -1"));
164 thread.Create(_L("Test Thread"),TestThread2,KDefaultStackSize,0x100,0x200,(TAny*)-1);
166 User::SetJustInTime(EFalse);
168 User::WaitForRequest(stat);
169 User::SetJustInTime(justInTime);
170 test(thread.ExitType()==EExitPanic);
171 CLOSE_AND_WAIT(thread);
173 test.Next(_L("Set panics for KMaxSuffices"));
174 thread.Create(_L("Test Thread"),TestThread2,KDefaultStackSize,0x100,0x200,(TAny*)KMaxSuffixes);
176 User::SetJustInTime(EFalse);
178 User::WaitForRequest(stat);
179 User::SetJustInTime(justInTime);
180 test(thread.ExitType()==EExitPanic);
181 CLOSE_AND_WAIT(thread);
188 test.Next(_L("TAmPmName"));
190 test(name1.Compare(_L("am"))==KErrNone);
191 TAmPmName name2(EPm);
192 test(name2.Compare(_L("pm"))==KErrNone);
194 test(name1.Compare(_L("pm"))==KErrNone);
197 void TestCurrencySymbol()
199 test.Next(_L("TCurrencySymbol"));
200 TCurrencySymbol name;
201 test(name.Compare(_L("\xA3"))==KErrNone);
204 test(name.Compare(_L("\xA3"))!=KErrNone);
206 test(name.Compare(_L("\xA3"))==KErrNone);
207 name.Copy(_L("Syphilis"));
208 test(name.Compare(_L("\xA3"))!=KErrNone);
209 test(name.Compare(_L("Syphilis"))==KErrNone);
210 User::SetCurrencySymbol(name);
211 TCurrencySymbol name2;
212 test(name2.Compare(_L("Syphilis"))==KErrNone);
213 name2.Copy(_L("\xA3"));
214 User::SetCurrencySymbol(name2);
216 test(name.Compare(_L("\xA3"))==KErrNone);
219 GLDEF_C TInt E32Main()
229 TestCurrencySymbol();