Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,392 @@
2010-05-14 Damien Diederen <dd@crosstwine.com>
* IdnMappingTest.cs: U+0221 is not unassigned anymore, use U+18B0
U+0221 is LATIN SMALL LETTER D WITH CURL in Unicode 4.0,
and is recognized as a valid letter in recent versions of the
.NET framework. This causes GetAsciiInvalid to (unexpectedly)
succeed, and the test to fail.
Use U+18B0 instead, which is unassigned as of Unicode 5.2 and
.NET 3.5 SP1.
2009-12-09 Jb Evain <jbevain@novell.com>
* StringInfoTest.cs: test the default constructor.
2009-10-29 Sebastien Pouliot <sebastien@ximian.com>
* CompareInfoTest.cs: Add test cases to validate parameters
2009-06-25 Zoltan Varga <vargaz@gmail.com>
* *.cs: Convert all tests to new-style nunit classes/methods.
2009-05-27 Zoltan Varga <vargaz@gmail.com>
* CultureInfoTest.cs: Fix the net 1.1 build.
2009-05-21 Atsushi Enomoto <atsushi@ximian.com>
* CultureInfoTest.cs : test zh-Hant.
2009-01-07 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for #462957.
2008-08-14 Atsushi Enomoto <atsushi@ximian.com>
* CultureInfoTest.cs : added test for bug #402128.
2008-04-02 Atsushi Enomoto <atsushi@ximian.com>
* SortKeyTest.cs : new test, for bug #376171.
2007-11-03 Atsushi Enomoto <atsushi@ximian.com>
* DateTimeFormatInfoTest.cs : enabled test for bug #332553.
2007-10-30 Atsushi Enomoto <atsushi@ximian.com>
* DateTimeFormatInfoTest.cs : added test for bug #335298.
2007-10-10 Gert Driesen <drieseng@users.sourceforge.net>
* DateTimeFormatInfoTest.cs: Added test for bug #332553.
2007-07-17 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs : true test for bug #81783 (overflown month in
AddMonths().)
2007-07-10 Atsushi Enomoto <atsushi@ximian.com>
* StringInfoTest.cs : new test.
2007-07-10 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs : enabled ToFourDigitYear() test from 5 years ago.
and added some more ToFourDigitYear() tests.
2007-07-09 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs : added GetWeekOfYear() test.
2007-07-05 Gert Driesen <drieseng@users.sourceforge.net>
* CultureInfoTest.cs: Fixed UseUserOverride tests to pass on systems
where invariant culture is default locale.
2007-07-03 Gert Driesen <drieseng@users.sourceforge.net>
* CultureInfoTest.cs: Added extra info in order to troubleshoot
buildbot failure on redhat9-i386.
2007-07-03 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs, EastAsianLunisolarCalendarTest.cs :
more tests needed mark as NotWorking.
2007-07-02 Gert Driesen <drieseng@users.sourceforge.net>
* EastAsianLunisolarCalenderTest.cs: Fixed build.
2007-07-02 Atsushi Enomoto <atsushi@ximian.com>
* EastAsianLunisolarCalendarTest.cs : new test, totally not-working.
* CalendarTest.cs : added couple of 2.0 tests. Some are not working.
2007-06-24 Gert Driesen <drieseng@users.sourceforge.net>
* CultureInfoTest.cs: Added exception tests when invoking NumberFormat
or DateTimeFormat on a neutral culture. Added tests for bug #81930.
No longer derive from deprecated Assertion class. Added tests for
GetCultureInfo (2.0).
2007-06-01 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs : test for bug #81783 and AddYears() for leap year
(similar issue).
2007-05-31 Rolf Bjarne Kvinge <RKvinge@novell.com>
* DateTimeFormatInfo.cs: Added EraName.
2007-05-25 Atsushi Enomoto <atsushi@ximian.com>
* IdnMappingTest.cs : new test.
2007-05-15 Atsushi Enomoto <atsushi@ximian.com>
* RegionInfoTest.cs : new tests.
2007-03-06 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for bug #79714.
2007-02-15 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for bug #80865.
2007-01-25 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for bug #80612.
2007-01-22 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Added Compare() tests for hyphens.
Removed NotWorking from previous new test (its existence wasn't
even recognized until today).
2007-01-11 Gert Driesen <drieseng@users.sourceforge.net>
* CompareInfoTest.cs: Added test for checking valid CompareOptions for
GetSortKey.
2006-12-25 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for OrdinalIgnoreCase versions
of IndexOf() and LastIndexOf(). Added Ordinal LastIndexOf() tests.
2006-11-27 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : why there was "return" before OrdinalIgnoreCase
tests ...
2006-06-08 Atsushi Enomoto <atsushi@ximian.com>
* DateTimeFormatInfoTest.cs : added test for bug #78569.
2006-04-25 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : seems like Microsoft had introduced several
bugs in CompareInfo, so marked many of them as NotDotNet.
2006-04-10 Atsushi Enomoto <atsushi@ximian.com>
* CultureInfoTest.cs : added test for bug #69652.
2006-03-21 Atsushi Enomoto <atsushi@ximian.com>
* CalendarTest.cs : added test for bug #76252.
2006-01-25 Atsushi Enomoto <atsushi@ximian.com>
* CultureInfoTest.cs : added test for bug #77347.
2005-12-08 Sebastien Pouliot <sebastien@ximian.com>
* DaylightTimeTest.cs: New. Serialization interop test cases.
2005-12-06 Sebastien Pouliot <sebastien@ximian.com>
* TextInfoTest.cs: Added new tests for serialization and for new 2.0
features.
2005-12-05 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : split the last case in NullCharacter() out
and marked it as NotDotNet (.NET is inconsistent between Compare
and IndexOf).
2005-11-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added NullCharacter() for bug #76702.
2005-11-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for Compare() w/ OrdinalIgnoreCase.
2005-11-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added more tests for some specific cultures
(say, Japanese) that have replacement contraction in ASCII range
and caused incorrect results for LastIndexOf() and all dependent
members.
2005-10-14 Ben Maurer <bmaurer@ximian.com>
* DateTimeFormatInfoTest.cs: New test to make sure we do not
return the same array from GetAllDateTimePatterns.
2005-09-27 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added testcase for bug #76243.
2005-09-20 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added empty string cases for IsPrefix/IsSuffix.
2005-09-09 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added another test for IsSuffix() that I found.
2005-08-14 Gert Driesen <drieseng@users.sourceforge.net>
* TextInfoTest.cs: Added ListSeparator test.
2005-08-11 Atsushi Enomoto <atsushi@ximian.com>
* CultureInfoTest.cs : added OptionalCalendars().
* CompareInfoTest.cs : added possible bug test for checkedFlags
optimization.
2005-07-15 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Some GetSortKey That tests got working.
2005-07-15 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Uncommented tests that got working. Added two
cornercase notworking LastIndexOf() tests.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : IsSuffix() extender tests got working.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for IndexOf() and LastIndexOf()
with ignorable source character. Added some non-working tests.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for IndexOf() and LastIndexOf()
that takes an expansion for target char.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : removed some FIXMEs. Added more extender tests.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : some special weight tests got working.
Commented on some FIXME tests why they are so.
2005-07-14 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Added extender tests for GetSortKey(),
Compare(), IsPrefix(), IndexOf() and LastIndexOf().
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Added Compare() test that contains expansion.
Fixed CompareSpecialWeight() which was not testing what I intended.
Added IsPrefix() tests with special weight (copying Compare() tests)
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added CompareSpecialWeight() and moved special
weight comparison there.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added GetSortKey() testcase that tests a
sequence of nonprimary character followed by an extender.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added more culture-sensitive "empty" test.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : Test for IndexOf() and LastIndexOf() with
"empty" target (in culture-sensitive context).
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added ignorable character in target for
IsPrefix/IsSuffix/IndexOf/LastIndexOf methods.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added more special weight testcases.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added Czech and Hungarian sorting tests.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added more diacritical tests.
2005-07-13 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added test for CJK mapping customization.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added GetSortKey() test for Thai.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added special weight GetSortKey() test.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added several GetSortKey() tests.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added shift weight testcases. Commented one
French sort thingy out.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added another French testcase.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added LastIndexOf() contraction cases and more.
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for IsSuffix(),
IndexOf(string,string) and LastIndexOf(string,string).
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for IsPrefix() and optionally
Compare() (which is currently used inside IsPrefix() which is
however wrong when it comes to managed collation).
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added tests for IndexOf() and LastIndexOf().
Fixed tests for Compare() - it should use overloaded ones of
the tested library (do not call overloaded tests themselves).
2005-07-12 Atsushi Enomoto <atsushi@ximian.com>
* CompareInfoTest.cs : added a few managed collation tests for
GetSortKey() and Compare() (they are ignored when managed collation
is off).
2005-06-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* GlobalizationAndDomains.cs: more tests for bugz.
2005-06-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* CultureInfoTest.cs: added test that tries setting the culture to a
neutral culture that is not the InvariantCulture.
2005-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* CultureInfoTest.cs: added new test.
2005-04-05 Atsushi Enomoto <atsushi@ximian.com>
* TextInfoTest.cs : added further ToTitleCase() tests.
2004-10-27 Ben Maurer <bmaurer@ximian.com>
* TextInfoTest.cs: Fix up migster's type
2003-12-19 Dick Porter <dick@ximian.com>
* CompareInfoTest.cs: Added some Compare tests
2002-12-21 Nick Drochak <ndrochak@gol.com>
* all: make tests build and run under nunit2

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
//
// DateTimeFormatInfo.cs
//
// Authors:
// Ben Maurer <bmaurer@andrew.cmu.edu>
//
// Copyright (C) 2005 Novell (http://www.novell.com)
// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class DateTimeFormatInfoTest
{
[Test]
public void GetAllDateTimePatterns_ret_diff_obj ()
{
// We need to return different objects for security reasons
DateTimeFormatInfo dtfi = CultureInfo.InvariantCulture.DateTimeFormat;
string [] one = dtfi.GetAllDateTimePatterns ();
string [] two = dtfi.GetAllDateTimePatterns ();
Assert.IsTrue (one != two);
}
[Test]
public void EraName ()
{
CultureInfo en_US = new CultureInfo ("en-US");
DateTimeFormatInfo dtfi = en_US.DateTimeFormat;
Assert.AreEqual ("AD", dtfi.GetAbbreviatedEraName (0), "#1");
Assert.AreEqual ("AD", dtfi.GetAbbreviatedEraName (1), "#7");
Assert.AreEqual ("A.D.", dtfi.GetEraName (0), "#8");
Assert.AreEqual ("A.D.", dtfi.GetEraName (1), "#2");
Assert.AreEqual (1, dtfi.GetEra ("A.D."), "#3");
Assert.AreEqual (1, dtfi.GetEra ("AD"), "#4");
Assert.AreEqual (-1, dtfi.GetEra ("C.E"), "#5");
Assert.AreEqual (-1, dtfi.GetEra ("Common Era"), "#6");
}
[Test] // bug #332553
public void MonthNames ()
{
CultureInfo c = CultureInfo.CreateSpecificCulture ("en");
string [] monthNamesA = c.DateTimeFormat.MonthNames;
Assert.AreEqual (13, monthNamesA.Length, "#A1");
Assert.AreEqual ("January", monthNamesA [0], "#A2");
Assert.AreEqual ("February", monthNamesA [1], "#A3");
Assert.AreEqual ("March", monthNamesA [2], "#A4");
Assert.AreEqual ("April", monthNamesA [3], "#A5");
Assert.AreEqual ("May", monthNamesA [4], "#A6");
Assert.AreEqual ("June", monthNamesA [5], "#A7");
Assert.AreEqual ("July", monthNamesA [6], "#A8");
Assert.AreEqual ("August", monthNamesA [7], "#A9");
Assert.AreEqual ("September", monthNamesA [8], "#A10");
Assert.AreEqual ("October", monthNamesA [9], "#A11");
Assert.AreEqual ("November", monthNamesA [10], "#A12");
Assert.AreEqual ("December", monthNamesA [11], "#A13");
Assert.AreEqual (string.Empty, monthNamesA [12], "#A14");
c.DateTimeFormat.MonthNames = c.DateTimeFormat.MonthNames;
string [] monthNamesB = c.DateTimeFormat.MonthNames;
Assert.AreEqual (monthNamesA, monthNamesB, "#B1");
Assert.IsFalse (object.ReferenceEquals (monthNamesA, monthNamesB), "#B2");
}
[Test]
public void TestSpecificCultureFormats_es_ES ()
{
CultureInfo ci = new CultureInfo ("es-ES");
DateTimeFormatInfo di = ci.DateTimeFormat;
Assert.AreEqual ("dddd, d' de 'MMMM' de 'yyyy", di.LongDatePattern, "#1");
Assert.AreEqual ("H:mm:ss", di.LongTimePattern, "#2");
Assert.AreEqual ("dddd, d' de 'MMMM' de 'yyyy H:mm:ss", di.FullDateTimePattern, "#3");
Assert.AreEqual ("MMMM' de 'yyyy", di.YearMonthPattern, "#4");
Assert.AreEqual ("d' de 'MMMM", di.MonthDayPattern, "#5");
}
[Test]
public void Clone ()
{
DateTimeFormatInfo dfi = (DateTimeFormatInfo) DateTimeFormatInfo.InvariantInfo.Clone ();
dfi.MonthNames[0] = "foo";
dfi.AbbreviatedDayNames[0] = "b1";
dfi.AbbreviatedMonthGenitiveNames[0] = "b2";
Assert.IsFalse (dfi.IsReadOnly, "#0");
Assert.AreEqual ("January", DateTimeFormatInfo.InvariantInfo.MonthNames [0], "#1");
Assert.AreEqual ("Sun", DateTimeFormatInfo.InvariantInfo.AbbreviatedDayNames[0], "#2");
Assert.AreEqual ("Jan", DateTimeFormatInfo.InvariantInfo.AbbreviatedMonthGenitiveNames[0], "#3");
}
[Test]
public void MonthGenitiveNames ()
{
var dfi = new CultureInfo ("cs-CZ").DateTimeFormat;
Assert.AreEqual ("ledna", dfi.MonthGenitiveNames[0], "#1");
Assert.AreEqual ("led", dfi.AbbreviatedMonthGenitiveNames[0], "#2");
}
[Test]
public void QuoteInValue ()
{
var culture = new CultureInfo("mt-MT");
Assert.AreEqual ("dddd, d' ta\\' 'MMMM yyyy", culture.DateTimeFormat.LongDatePattern);
}
#if !TARGET_JVM
[Test]
public void Bug78569 ()
{
DateTime dt = DateTime.Now;
CultureInfo ci = new CultureInfo ("en-GB");
string s = dt.ToString (ci);
DateTime dt2 = DateTime.Parse (s, ci);
Assert.AreEqual (dt.Month, dt2.Month);
}
#endif
}
}

View File

@@ -0,0 +1,92 @@
//
// BinaryFormatterTest.cs - Unit tests for
// System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Globalization;
using System.Runtime.Serialization.Formatters.Binary;
using NUnit.Framework;
namespace MonoTests.System.Globalization {
[TestFixture]
public class DaylightTimeTest {
[Test]
public void Constructor ()
{
DaylightTime dt = new DaylightTime (DateTime.MinValue, DateTime.MaxValue, TimeSpan.MinValue);
Assert.AreEqual (DateTime.MinValue, dt.Start, "Start");
Assert.AreEqual (DateTime.MaxValue, dt.End, "End");
Assert.AreEqual (TimeSpan.MinValue, dt.Delta, "Delta");
}
[Test]
public void SerializationRoundtrip ()
{
DaylightTime dt = new DaylightTime (DateTime.MinValue, DateTime.MaxValue, TimeSpan.MinValue);
BinaryFormatter bf = new BinaryFormatter ();
MemoryStream ms = new MemoryStream ();
bf.Serialize (ms, dt);
ms.Position = 0;
DaylightTime clone = (DaylightTime) bf.Deserialize (ms);
Assert.AreEqual (clone.Start, dt.Start, "Start");
Assert.AreEqual (clone.End, dt.End, "End");
Assert.AreEqual (clone.Delta, dt.Delta, "Delta");
}
static private byte[] serialized_daylighttime = {
0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x01, 0x00, 0x00, 0x00, 0x21, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x47, 0x6C, 0x6F, 0x62,
0x61, 0x6C, 0x69, 0x7A, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x44, 0x61, 0x79, 0x6C, 0x69, 0x67, 0x68,
0x74, 0x54, 0x69, 0x6D, 0x65, 0x03, 0x00, 0x00, 0x00, 0x07, 0x6D, 0x5F, 0x73, 0x74, 0x61, 0x72, 0x74,
0x05, 0x6D, 0x5F, 0x65, 0x6E, 0x64, 0x07, 0x6D, 0x5F, 0x64, 0x65, 0x6C, 0x74, 0x61, 0x00, 0x00, 0x00,
0x0D, 0x0D, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x37, 0xF4, 0x75, 0x28,
0xCA, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0B
};
[Test]
public void DeserializeKnownValue ()
{
MemoryStream ms = new MemoryStream (serialized_daylighttime);
#if TARGET_JVM
BinaryFormatter bf = (BinaryFormatter)vmw.@internal.remoting.BinaryFormatterUtils.CreateBinaryFormatter (false);
#else
BinaryFormatter bf = new BinaryFormatter ();
#endif // TARGET_JVM
DaylightTime dt = (DaylightTime) bf.Deserialize (ms);
Assert.AreEqual (DateTime.MinValue, dt.Start, "Start");
Assert.AreEqual (DateTime.MaxValue, dt.End, "End");
Assert.AreEqual (TimeSpan.MinValue, dt.Delta, "Delta");
}
}
}

View File

@@ -0,0 +1,230 @@
// EastAsianLunisolarCalendarTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc. http://www.novell.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class EastAsianLunisolarCalendarTest
{
static ChineseLunisolarCalendar cn = new ChineseLunisolarCalendar ();
static JapaneseLunisolarCalendar jp = new JapaneseLunisolarCalendar ();
static TaiwanLunisolarCalendar tw = new TaiwanLunisolarCalendar ();
static KoreanLunisolarCalendar kr = new KoreanLunisolarCalendar ();
[Test]
[Category ("NotWorking")]
public void ToDateTime ()
{
Assert.AreEqual (new DateTime (2000, 2, 5), cn.ToDateTime (2000, 1, 1, 0, 0, 0, 0), "cn1");
Assert.AreEqual (new DateTime (2000, 2, 5), jp.ToDateTime (12, 1, 1, 0, 0, 0, 0), "jp1"); // since 1988 (current epoch)
Assert.AreEqual (new DateTime (2000, 2, 5), tw.ToDateTime (89, 1, 1, 0, 0, 0, 0), "tw1"); // since 1912 (current epoch)
Assert.AreEqual (new DateTime (2000, 2, 5), kr.ToDateTime (2000, 1, 1, 0, 0, 0, 0), "kr1");
Assert.AreEqual (new DateTime (2001, 1, 24), cn.ToDateTime (2001, 1, 1, 0, 0, 0, 0), "cn2");
Assert.AreEqual (new DateTime (2001, 1, 24), jp.ToDateTime (13, 1, 1, 0, 0, 0, 0), "jp2");
Assert.AreEqual (new DateTime (2001, 1, 24), tw.ToDateTime (90, 1, 1, 0, 0, 0, 0), "tw2");
Assert.AreEqual (new DateTime (2001, 1, 24), kr.ToDateTime (2001, 1, 1, 0, 0, 0, 0), "kr2");
Assert.AreEqual (new DateTime (2002, 2, 12), cn.ToDateTime (2002, 1, 1, 0, 0, 0, 0), "cn3");
Assert.AreEqual (new DateTime (2002, 2, 12), jp.ToDateTime (14, 1, 1, 0, 0, 0, 0), "jp3");
Assert.AreEqual (new DateTime (2002, 2, 12), tw.ToDateTime (91, 1, 1, 0, 0, 0, 0), "tw3");
Assert.AreEqual (new DateTime (2002, 2, 12), kr.ToDateTime (2002, 1, 1, 0, 0, 0, 0), "kr3");
// actually it is 5th month which is leap, but that
// does not afffect on resulting DateTime
Assert.AreEqual (new DateTime (2001, 5, 23), cn.ToDateTime (2001, 5, 1, 0, 0, 0, 0), "cn4");
Assert.AreEqual (new DateTime (2001, 5, 23), jp.ToDateTime (13, 5, 1, 0, 0, 0, 0), "jp4");
Assert.AreEqual (new DateTime (2001, 5, 23), tw.ToDateTime (90, 5, 1, 0, 0, 0, 0), "tw4");
Assert.AreEqual (new DateTime (2001, 5, 23), kr.ToDateTime (2001, 5, 1, 0, 0, 0, 0), "kr4");
// here the leap month works.
Assert.AreEqual (new DateTime (2002, 2, 11), cn.ToDateTime (2001, 13, 30, 0, 0, 0, 0), "cn5");
Assert.AreEqual (new DateTime (2002, 2, 11), jp.ToDateTime (13, 13, 30, 0, 0, 0, 0), "jp5");
Assert.AreEqual (new DateTime (2002, 2, 11), tw.ToDateTime (90, 13, 30, 0, 0, 0, 0), "tw5");
Assert.AreEqual (new DateTime (2002, 2, 11), kr.ToDateTime (2001, 13, 30, 0, 0, 0, 0), "kr5");
Assert.AreEqual (cn.MinSupportedDateTime, cn.ToDateTime (1901, 1, 1, 0, 0, 0, 0), "cn6");
Assert.AreEqual (jp.MinSupportedDateTime, jp.ToDateTime (35, 1, 1, 0, 0, 0, 0, 3), "jp6"); // 1960-1-1
Assert.AreEqual (tw.MinSupportedDateTime, tw.ToDateTime (1, 1, 1, 0, 0, 0, 0), "tw6"); // 1912
Assert.AreEqual (kr.MinSupportedDateTime, kr.ToDateTime (918, 1, 1, 0, 0, 0, 0), "kr6");
Assert.AreEqual (jp.MinSupportedDateTime, cn.ToDateTime (1960, 1, 1, 0, 0, 0, 0), "jp-cn1");
}
[Test]
[Category ("NotWorking")]
public void ToDateTimeOutOfRange ()
{
try {
cn.ToDateTime (1900, 12, 29, 23, 59, 59, 0);
Assert.Fail ("#cn1");
} catch (ArgumentOutOfRangeException) {
}
try { // non-leap
cn.ToDateTime (2000, 13, 29, 23, 59, 59, 0);
Assert.Fail ("#cn2");
} catch (ArgumentOutOfRangeException) {
}
}
[Test]
[Category ("NotWorking")]
public void GetYear ()
{
Assert.AreEqual (1901, cn.GetYear (new DateTime (1901, 2, 19, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#1");
Assert.AreEqual (1901, cn.GetYear (new DateTime (1902, 2, 07, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#2");
Assert.AreEqual (1902, cn.GetYear (new DateTime (1902, 2, 08, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#3");
Assert.AreEqual (1902, cn.GetYear (new DateTime (1903, 1, 28, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#4");
Assert.AreEqual (1903, cn.GetYear (new DateTime (1903, 1, 29, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#5");
// there was a leap month
Assert.AreEqual (1903, cn.GetYear (new DateTime (1904, 2, 15, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#6");
Assert.AreEqual (1904, cn.GetYear (new DateTime (1904, 2, 16, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#7");
}
[Test]
[Category ("NotWorking")]
public void GetYear2 ()
{
Assert.AreEqual (1999, cn.GetYear (new DateTime (2000, 2, 4, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#1");
Assert.AreEqual (2000, cn.GetYear (new DateTime (2000, 2, 5, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#2");
Assert.AreEqual (11, jp.GetYear (new DateTime (2000, 2, 4, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#3");
Assert.AreEqual (12, jp.GetYear (new DateTime (2000, 2, 5, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#4");
Assert.AreEqual (88, tw.GetYear (new DateTime (2000, 2, 4, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#5");
Assert.AreEqual (89, tw.GetYear (new DateTime (2000, 2, 5, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#6");
Assert.AreEqual (1999, cn.GetYear (new DateTime (2000, 2, 4, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#7");
Assert.AreEqual (2000, cn.GetYear (new DateTime (2000, 2, 5, 0, 0, 0, DateTimeKind.Utc).ToLocalTime ()), "#8");
}
bool [] leapYears = new bool [] {
false, true, false, false, true,
false, true, false, false, true,
false, false, true, false, true,
false, false, true, false, // 19 years rotation
};
[Test]
[Category ("NotWorking")]
public void IsLeapYear ()
{
//Assert.IsFalse (cn.IsLeapYear (1901), "#cn1901");
//Assert.AreEqual (0, cn.GetSexagenaryYear (cn.MinSupportedDateTime), "#60cn1");
for (int i = 0; i < 60; i++)
Assert.AreEqual (leapYears [i % 19], cn.IsLeapYear (2000 + i), "cn" + i);
for (int i = 0; i < 48; i++) // only 1-to-61 are allowed
Assert.AreEqual (leapYears [i % 19], jp.IsLeapYear (12 + i), "jp" + i);
for (int i = 0; i < 50; i++)
Assert.AreEqual (leapYears [i % 19], tw.IsLeapYear (89 + i), "tw" + i);
for (int i = 0; i < 50; i++)
Assert.AreEqual (leapYears [i % 19], kr.IsLeapYear (2000 + i), "kr" + i);
// 2033 Rain-Water jieqi (usui) new year day is in
// the leap month.
Assert.IsTrue (cn.IsLeapYear (2033), "cn2033");
Assert.IsFalse (cn.IsLeapYear (2034), "cn2034");
}
[Test]
[Category ("NotWorking")]
public void IsLeapMonth ()
{
Dictionary<int,int> d = new Dictionary<int,int> ();
d [2001] = 5;
d [2004] = 3;
d [2006] = 8;
d [2009] = 6;
d [2012] = 5;
d [2014] = 10;
d [2017] = 7;
d [2020] = 5;
d [2023] = 3;
d [2025] = 7; // hmm ...
d [2028] = 6;
d [2031] = 4; // hmmmm ...
d [2033] = 12; // hmmmmmm ...
d [2036] = 7;
for (int y = 2000; y < 2038; y++)
for (int m = 1; m <= 12; m++)
Assert.AreEqual (d.ContainsKey (y) && d [y] == m, cn.IsLeapMonth (y, m), "cn" + y + "/" + m);
d = new Dictionary<int,int> ();
d [90] = 5;
d [93] = 3;
d [95] = 8;
d [98] = 6;
d [101] = 5;
d [103] = 10;
d [106] = 7;
d [109] = 5;
d [112] = 3;
d [114] = 7;
d [117] = 6;
d [120] = 4;
d [122] = 12;
d [125] = 7;
for (int y = 89; y < 127; y++)
for (int m = 1; m <= 12; m++)
Assert.AreEqual (d.ContainsKey (y) && d [y] == m, tw.IsLeapMonth (y, m), "tw" + y + "/" + m);
d = new Dictionary<int,int> ();
d [13] = 5;
d [16] = 3;
d [18] = 8;
d [21] = 6;
d [24] = 4;
d [26] = 10;
d [29] = 6;
for (int y = 12; y < 32; y++)
for (int m = 1; m <= 12; m++)
Assert.AreEqual (d.ContainsKey (y) && d [y] == m, jp.IsLeapMonth (y, m), "jp" + y + "/" + m);
d = new Dictionary<int,int> ();
d [2001] = 5;
d [2004] = 3;
d [2006] = 8;
d [2009] = 6;
d [2012] = 4;
d [2014] = 10;
d [2017] = 6;
for (int y = 2000; y < 2020; y++)
for (int m = 1; m <= 12; m++)
Assert.AreEqual (d.ContainsKey (y) && d [y] == m, kr.IsLeapMonth (y, m), "kr" + y + "/" + m);
}
}
}
#endif

View File

@@ -0,0 +1,197 @@
//
// IdnMappingTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System.IO;
using System;
using System.Globalization;
using System.Threading;
using System.Text;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class IdnMappingTest
{
void GetAscii (IdnMapping m, string source, string expected, object label)
{
Assert.AreEqual (expected, m.GetAscii (source), label != null ? label.ToString () : expected);
}
void GetAsciiInvalid (IdnMapping m, string s, object label)
{
try {
m.GetAscii (s);
Assert.Fail (label != null ? label.ToString () + ":" + s : s);
} catch (ArgumentException) {
}
}
void GetUnicode (IdnMapping m, string source, string expected, object label)
{
Assert.AreEqual (expected, m.GetUnicode (source), label != null ? label.ToString () : expected);
}
void GetUnicodeInvalid (IdnMapping m, string s, object label)
{
try {
m.GetUnicode (s);
Assert.Fail (label != null ? label.ToString () + ":" + s : s);
} catch (ArgumentException) {
}
}
[Test]
public void GetAsciiInvalid ()
{
// hmm... according to RFC 3490, there are couple of
// invalid characters in RFC 3491 [Nameprop] ...
// comment out them for now.
IdnMapping m = new IdnMapping ();
GetAsciiInvalid (m, "\x0", 1);
GetAsciiInvalid (m, "\xD\xA", 2);
GetAsciiInvalid (m, "\x1F", 3);
GetAsciiInvalid (m, "\x7F", 4);
GetAsciiInvalid (m, "\x80", 5);
// GetAsciiInvalid (m, "\xA0", 6);
// GetAsciiInvalid (m, "\u1680", 7);
GetAsciiInvalid (m, "\u200E", 8);
// GetAsciiInvalid (m, "\u0341", 9);
GetAsciiInvalid (m, "\uE000", 10);
GetAsciiInvalid (m, "\uFFFF", 11);
GetAsciiInvalid (m, "\u2028", 12);
GetAsciiInvalid (m, "\uD800", 13);
// GetAsciiInvalid (m, "\u3000", 14);
}
[Test]
public void GetAscii ()
{
IdnMapping m = new IdnMapping ();
GetAscii (m, "www.mono-project.com", "www.mono-project.com", 1);
GetAscii (m, "a\uFF61b", "a.b", 2);
// umm... does it reject anything larger than U+FFFF ??
// GetAscii (m, "\uD800\uDC00", "", 3);
// hmm, according to RFC 3490, ToASCII never changes
// the input whose codepoints are all within ASCII.
GetAscii (m, "A\uFF61B", "a.b", 4);
GetAscii (m, "A.B", "A.B", 5); // no lowercasing
}
[Test]
public void Dots ()
{
IdnMapping m = new IdnMapping ();
GetAsciiInvalid (m, ".", 1);
GetAsciiInvalid (m, "\uFF61", 2);
GetAscii (m, "Am running now.", "Am running now.", 3);
GetAsciiInvalid (m, ".bashrc", 4);
}
[Test]
public void UnassignedCharacter ()
{
IdnMapping m = new IdnMapping ();
GetAsciiInvalid (m, "\u18b0.com", 1);
m.AllowUnassigned = true;
GetAscii (m, "\u18b0.com", "xn--6bf.com", 2);
}
[Test]
public void UseStd3AsciiRules ()
{
IdnMapping m = new IdnMapping ();
GetAscii (m, "-_-.com", "-_-.com", 1);
m.UseStd3AsciiRules = true;
GetAsciiInvalid (m, "a b.com", 1.5);
GetAsciiInvalid (m, "_.com", 2);
GetAsciiInvalid (m, "-abc.com", 3);
GetAscii (m, "abc-def.com", "abc-def.com", 4); // hyphen in the middle is okay
GetAsciiInvalid (m, "abc-.def.com", 5); // hyphen is *not* in the middle.
}
[Test]
public void AcePrefix ()
{
IdnMapping m = new IdnMapping ();
GetAscii (m, "bl--.com", "bl--.com", 1); // only ascii
GetAscii (m, "bl--\xC0.com", "xn--bl---3na.com", 2);
GetAscii (m, "xn--.com", "xn--.com", 3); // only ascii
GetAsciiInvalid (m, "xn--\xC0.com", 4);
GetAsciiInvalid (m, "xN--\xC0.com", 5);
GetAsciiInvalid (m, "Xn--\xC0.com", 6);
GetAsciiInvalid (m, "XN--\xC0.com", 7);
GetAscii (m, "xN\xC0.com", "xn--xn-kia.com", 8);
GetAscii (m, "bl--\xC0.wl--\xC0.com", "xn--bl---3na.xn--wl---3na.com", 9);
}
[Test]
public void GetAsciiRFC3492Examples ()
{
IdnMapping m = new IdnMapping ();
// 3<nen>B<gumi><kin><pachi><sen><sei>
GetAscii (m, "3\u5E74B\u7D44\u91D1\u516B\u5148\u751F", "xn--3b-ww4c5e180e575a65lsy2b", "(L)");
// Maji<de>Koi<suru>5<byoumae>
GetAscii (m, "Maji\u3067Koi\u3059\u308B5\u79D2\u524D", "xn--majikoi5-783gue6qz075azm5e", "(P)");
}
[Test]
public void GetUnicode ()
{
IdnMapping m = new IdnMapping ();
GetAscii (m, "www.mono-project.com", "www.mono-project.com", 1);
GetAscii (m, "a\uFF61b", "a.b", 2);
// umm... does it reject anything larger than U+FFFF ??
// GetAscii (m, "\uD800\uDC00", "", 3);
// hmm, according to RFC 3490, ToASCII never changes
// the input whose codepoints are all within ASCII.
GetAscii (m, "A\uFF61B", "a.b", 4);
GetAscii (m, "A.B", "A.B", 5); // no lowercasing
}
[Test]
public void GetUnicodeRFC3492Examples ()
{
// uppercases in the ASCII strings are ignored.
IdnMapping m = new IdnMapping ();
// 3<nen>B<gumi><kin><pachi><sen><sei>
GetUnicode (m, "xn--3B-ww4c5e180e575a65lsy2b", "3\u5E74b\u7D44\u91D1\u516B\u5148\u751F", "(L)");
// Maji<de>Koi<suru>5<byoumae>
GetUnicode (m, "xn--MajiKoi5-783gue6qz075azm5e", "maji\u3067koi\u3059\u308B5\u79D2\u524D", "(P)");
}
}
}
#endif

View File

@@ -0,0 +1,57 @@
//
// NumberFormatInfoTest.cs
//
// Authors:
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2013 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.Globalization;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class NumberFormatInfoTest
{
[Test]
public void CurrencyDecimalDigits ()
{
CultureInfo c;
c = CultureInfo.GetCultureInfo ("id-ID");
Assert.AreEqual (0, c.NumberFormat.CurrencyDecimalDigits, "#1");
c = CultureInfo.GetCultureInfo ("is-IS");
Assert.AreEqual (0, c.NumberFormat.CurrencyDecimalDigits, "#2");
c = CultureInfo.InvariantCulture;
Assert.AreEqual (2, c.NumberFormat.CurrencyDecimalDigits, "#3");
}
}
}

View File

@@ -0,0 +1,95 @@
//
// System.Globalization.RegionInfoTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// (c) 2007 Novell, Inc. (http://www.novell.com)
//
using NUnit.Framework;
using System.IO;
using System;
using System.Globalization;
using System.Threading;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class RegionInfoTest
{
[Test]
public void RegionByName ()
{
string [] names = new string [] {
"AR", "ES", "HK", "TW", "US"};
foreach (string name in names)
new RegionInfo (name);
}
[Test]
public void RegionByWrongName ()
{
string [] names = new string [] {
"en", "EN"};
foreach (string name in names) {
try {
new RegionInfo (name);
Assert.Fail ("should be invalid: " + name);
} catch (ArgumentException) {
}
}
try {
new RegionInfo ("2342#");
Assert.Fail ("#2");
} catch (ArgumentException) {
}
}
[Test]
public void RegionByLocaleName ()
{
string [] names = new string [] {
"en-US", "zh-TW"};
foreach (string name in names)
new RegionInfo (name);
}
[Test]
// This can fail on systems where CultureInfo.CurrentCulture==null
[Category ("NotWorking")]
public void CurrentRegion ()
{
Assert.IsNotNull (RegionInfo.CurrentRegion, "CurrentRegion");
}
[Test]
public void HongKong ()
{
// https://bugzilla.xamarin.com/show_bug.cgi?id=3476
RegionInfo hk = new RegionInfo ("HK");
// subset that match in both .NET 4 (Win7) and Mono
Assert.AreEqual (hk.CurrencyEnglishName, "Hong Kong Dollar", "CurrencyEnglishName");
Assert.IsTrue (hk.IsMetric, "IsMetric");
Assert.AreEqual (hk.ISOCurrencySymbol, "HKD", "ISOCurrencySymbol");
Assert.AreEqual (hk.Name, "HK", "Name");
Assert.AreEqual (hk.TwoLetterISORegionName, "HK", "TwoLetterISORegionName");
// the bug messed the order leading to DisplayName used for TLA (mono returns String.Empty)
Assert.IsTrue (hk.ThreeLetterISORegionName.Length <= 3, "ThreeLetterISORegionName");
Assert.IsTrue (hk.ThreeLetterWindowsRegionName.Length <= 3, "ThreeLetterWindowsRegionName");
}
[Test]
public void Equals ()
{
var a = new RegionInfo (0x414);
var b = new RegionInfo (0x43B);
Assert.AreEqual (a, b);
}
}
}

View File

@@ -0,0 +1,40 @@
//
// SortKeyTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class SortKeyTest
{
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CompareNull ()
{
// bug #376171
SortKey.Compare (null, null);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void CompareNull2 ()
{
// bug #376171
SortKey.Compare (CultureInfo.InvariantCulture.CompareInfo.GetSortKey ("A"), null);
}
}
}

View File

@@ -0,0 +1,93 @@
//
// StringInfoTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class StringInfoTest
{
[Test]
public void GetNextTextElement ()
{
Assert.AreEqual ("A", StringInfo.GetNextTextElement ("ABC", 0), "#1");
Assert.AreEqual ("C", StringInfo.GetNextTextElement ("ABC", 2), "#2");
Assert.AreEqual ("A\u0330", StringInfo.GetNextTextElement ("A\u0330BC", 0), "#3");
Assert.AreEqual ("B", StringInfo.GetNextTextElement ("A\u0330BC", 2), "#4");
// hmm ...
#if NET_2_0 // it causes ArgumentOutOfRangeException in 1.x, not worthy to test it anymore
Assert.AreEqual (String.Empty, StringInfo.GetNextTextElement ("A\u0330BC", 4), "#4");
#endif
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void GetNextTextElementOutOfRange1 ()
{
StringInfo.GetNextTextElement ("ABC", -1);
}
#if NET_2_0
[Test]
public void LengthInTextElements ()
{
Assert.AreEqual (3, new StringInfo ("ABC").LengthInTextElements, "#1");
Assert.AreEqual (5, new StringInfo (" ABC ").LengthInTextElements, "#2");
Assert.AreEqual (3, new StringInfo ("A\u0330BC\u0330").LengthInTextElements, "#3");
Assert.AreEqual (3, new StringInfo ("A\u0330\u0331BC\u0330").LengthInTextElements, "#4");
}
[Test]
public void SubstringByTextElements ()
{
StringInfo si = new StringInfo ("A\u0330BC\u0330");
Assert.AreEqual ("A\u0330BC\u0330", si.SubstringByTextElements (0), "#1");
Assert.AreEqual ("BC\u0330", si.SubstringByTextElements (1), "#2");
Assert.AreEqual ("C\u0330", si.SubstringByTextElements (2), "#3");
}
[Test]
public void DefaultConstructor ()
{
var info = new StringInfo ();
Assert.AreEqual (string.Empty, info.String);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void SubstringByTextElementsOutOfRange1 ()
{
new StringInfo ("A\u0330BC\u0330").SubstringByTextElements (-1);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void SubstringByTextElementsOutOfRange2 ()
{
new StringInfo ("A\u0330BC\u0330").SubstringByTextElements (4);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void SubstringByTextElementsOutOfRange3 ()
{
new StringInfo (String.Empty).SubstringByTextElements (0);
}
#endif
}
}

View File

@@ -0,0 +1,192 @@
// TextInfoTest.cs - NUnit Test Cases for the
// System.Globalization.TextInfo class
//
// Miguel de Icaza <miguel@ximian.com>
//
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
using NUnit.Framework;
using System;
using System.Globalization;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace MonoTests.System.Globalization
{
[TestFixture]
public class TextInfoTest {
[Test]
public void TitleCase ()
{
TextInfo ti = new CultureInfo ("en-US", false).TextInfo;
Assert.AreEqual (" The Dog", ti.ToTitleCase (" the dog"), "#1");
Assert.AreEqual (" The Dude", ti.ToTitleCase (" The Dude"), "#2");
Assert.AreEqual ("La Guerra Yla Paz", ti.ToTitleCase ("la Guerra yLa pAz"), "#3");
Assert.AreEqual ("\tTab\tAnd\tPeace", ti.ToTitleCase ("\ttab\taNd\tpeaCE"), "#4");
Assert.AreEqual ("This_Is\uFE58A\u0095String\u06D4With\uFE33Separators", ti.ToTitleCase ("this_is\uFE58a\u0095string\u06D4with\uFE33separators"), "#5");
}
[Test]
public void ListSeparator ()
{
TextInfo ti;
ti = new CultureInfo ("en-US", false).TextInfo;
Assert.AreEqual (",", ti.ListSeparator, "#1");
ti = CultureInfo.InvariantCulture.TextInfo;
Assert.AreEqual (",", ti.ListSeparator, "#2");
ti = new CultureInfo ("nl-BE", false).TextInfo;
Assert.AreEqual (";", ti.ListSeparator, "#3");
}
[Test]
public void TitleCase2 ()
{
foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
Check (ci, "AB", "AB");
Check (ci, "ab", "Ab");
Check (ci, "aB", "Ab");
Check (ci, "1Ab", "1Ab");
Check (ci, "abc AB ab aB Ab ABc 1AB 1Ab 1ab 1aB",
"Abc AB Ab Ab Ab Abc 1AB 1Ab 1Ab 1Ab");
Check (ci, "LJ", "LJ");
Check (ci, "lj", "Lj");
Check (ci, "lJ", "Lj");
Check (ci, "lj abc ljabc", "Lj Abc Ljabc");
Check (ci, "ab", "Ab");
// Some greek titlecase characters
Check (ci, "\u01c4", "\u01c5");
Check (ci, "\u01c5", "\u01c5");
Check (ci, "\u01c6", "\u01c5");
Check (ci, "\u01ca", "\u01cb");
Check (ci, "\u01cb", "\u01cb");
Check (ci, "\u01cc", "\u01cb");
// Roman numbers are not converted unlike ToUpper().
Check (ci, "\u2170", "\u2170");
Check (ci, "\u24e9", "\u24e9");
}
}
private void Check (CultureInfo ci, string src, string expected)
{
Assert.AreEqual (expected, ci.TextInfo.ToTitleCase (src), src + " at culture " + ci.LCID);
}
private void CompareProperties (TextInfo t1, TextInfo t2, bool compareReadOnly)
{
Assert.AreEqual (t1.ANSICodePage, t2.ANSICodePage, "ANSICodePage");
Assert.AreEqual (t1.EBCDICCodePage, t2.EBCDICCodePage, "EBCDICCodePage");
Assert.AreEqual (t1.ListSeparator, t2.ListSeparator, "ListSeparator");
Assert.AreEqual (t1.MacCodePage, t2.MacCodePage, "MacCodePage");
Assert.AreEqual (t1.OEMCodePage, t2.OEMCodePage, "OEMCodePage");
Assert.AreEqual (t1.CultureName, t2.CultureName, "CultureName");
if (compareReadOnly)
Assert.AreEqual (t1.IsReadOnly, t2.IsReadOnly, "IsReadOnly");
//FIXME Assert.AreEqual (t1.IsRightToLeft, t2.IsRightToLeft, "IsRightToLeft");
Assert.AreEqual (t1.LCID, t2.LCID, "LCID");
}
[Test]
[Category ("NotWorking")] // OnDeserialization isn't completed
public void SerializationRoundtrip ()
{
TextInfo enus = new CultureInfo ("en-US").TextInfo;
BinaryFormatter bf = new BinaryFormatter ();
MemoryStream ms = new MemoryStream ();
bf.Serialize (ms, enus);
ms.Position = 0;
TextInfo clone = (TextInfo) bf.Deserialize (ms);
CompareProperties (enus, clone, true);
}
[Test]
public void Clone ()
{
TextInfo enus = new CultureInfo ("en-US").TextInfo;
TextInfo clone = (TextInfo) enus.Clone ();
CompareProperties (enus, clone, true);
}
[Test]
public void Clone_ReadOnly ()
{
TextInfo enus = TextInfo.ReadOnly (new CultureInfo ("en-US").TextInfo);
Assert.IsTrue (enus.IsReadOnly, "IsReadOnly-1");
TextInfo clone = (TextInfo) enus.Clone ();
Assert.IsFalse (clone.IsReadOnly, "IsReadOnly-2");
CompareProperties (enus, clone, false);
// cloned item is *NOT* read-only
}
[Test]
public void ReadOnly ()
{
TextInfo enus = new CultureInfo ("en-US").TextInfo;
Assert.IsFalse (enus.IsReadOnly, "IsReadOnly-1");
TextInfo ro = TextInfo.ReadOnly (enus);
Assert.IsTrue (ro.IsReadOnly, "IsReadOnly-2");
CompareProperties (enus, ro, false);
}
[Test]
public void IsRightToLeft ()
{
foreach (CultureInfo ci in CultureInfo.GetCultures (CultureTypes.AllCultures)) {
switch (ci.LCID) {
case 1: // ar
case 13: // he
case 32: // ur
case 41: // fa
case 0x63: // ps
case 90: // syr
case 101: // div
case 1025: // ar-SA
case 1037: // he-IL
case 1056: // ur-PK
case 1065: // ra-IR
case 1114: // syr-SY
case 1125: // div-MV
case 2049: // ar-IQ
case 3073: // ar-EG
case 4097: // ar-LY
case 5121: // ar-DZ
case 6145: // ar-MA
case 7169: // ar-TN
case 8193: // ar-OM
case 9217: // ar-YE
case 10241: // ar-SY
case 11265: // ar-JO
case 12289: // ar-LB
case 13313: // ar-KW
case 14337: // ar-AE
case 15361: // ar-BH
case 16385: // ar-QA
case 0x463: // ps-AF
Assert.IsTrue (ci.TextInfo.IsRightToLeft, ci.Name);
break;
default:
Assert.IsFalse (ci.TextInfo.IsRightToLeft, ci.Name);
break;
}
}
}
[Test]
public void Deserialization ()
{
TextInfo ti = CultureInfo.CurrentCulture.TextInfo;
IDeserializationCallback dc = (ti as IDeserializationCallback);
dc.OnDeserialization (null);
}
}
}