Imported Upstream version 4.2.0.179

Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent aa7da660d6
commit c042cd0c52
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -274,20 +274,6 @@ namespace MonoTests.System.IO
}
}
[Test]
public void TestReadUnicode ()
{
char testChar1 = 'H';
using (var stream = new MemoryStream())
using (var writer = new BinaryWriter(stream, Encoding.Unicode, true))
using (var reader = new BinaryReader(stream, Encoding.Unicode))
{
writer.Write(testChar1);
stream.Position = 0;
Assert.AreEqual ('H', reader.ReadChar ());
}
}
//-TODO: (TestRead[Type]*) Verify the ReadBoolean, ReadByte ....
// ReadBoolean, ReadByte, ReadChar, ReadInt32 Done
@@ -1076,7 +1062,7 @@ namespace MonoTests.System.IO
}
[Test]
[ExpectedException(typeof(EndOfStreamException))]
[ExpectedException(typeof(IOException))]
public void ReadDecimalException ()
{
MemoryStream stream = new MemoryStream (new byte [] {0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0 ,87, 98, 0, 0, 0, 0, 0});
@@ -1576,5 +1562,22 @@ namespace MonoTests.System.IO
}
}
}
// Bug Xamarin #30171
[Test]
public void BinaryReaderRegressionMono40 ()
{
char testChar1 = 'H';
using (var stream = new MemoryStream()){
using (var writer = new BinaryWriter(stream, Encoding.Unicode, true)){
using (var reader = new BinaryReader(stream, Encoding.Unicode)) {
writer.Write(testChar1);
stream.Position = 0;
char testchar2 = reader.ReadChar();
Assert.AreEqual (testChar1, testchar2);
}
}
}
}
}
}

View File

@@ -87,12 +87,13 @@ namespace MonoTests.System.IO
[Test]
public void CtorFileNotFoundException_Mode_Open ()
{
const string file_name = "thisfileshouldnotexist.test";
// absolute path
string path = TempFolder + DSC + "thisfileshouldnotexists.test";
string path = TempFolder + DSC + file_name;
DeleteFile (path);
FileStream stream = null;
try {
stream = new FileStream (TempFolder + DSC + "thisfileshouldnotexists.test", FileMode.Open);
stream = new FileStream (TempFolder + DSC + file_name, FileMode.Open);
Assert.Fail ("#A1");
} catch (FileNotFoundException ex) {
Assert.AreEqual (typeof (FileNotFoundException), ex.GetType (), "#A2");
@@ -111,14 +112,18 @@ namespace MonoTests.System.IO
// relative path
string orignalCurrentDir = Directory.GetCurrentDirectory ();
Directory.SetCurrentDirectory (TempFolder);
// If TempFolder is a symlink, Mono will follow it and ex.FileName below will contain
// the real directory name, not that of the TempFolder symlink and the test will fail
// (happens e.g. on Android M)
string realTempDir = Directory.GetCurrentDirectory ();
path = realTempDir + DSC + file_name;
try {
stream = new FileStream ("thisfileshouldnotexists.test", FileMode.Open);
stream = new FileStream (file_name, FileMode.Open);
Assert.Fail ("#B1");
} catch (FileNotFoundException ex) {
Assert.AreEqual (typeof (FileNotFoundException), ex.GetType (), "#B2");
// under OSX 'var' is a symlink to 'private/var'
if (MacOSX)
path = "/private" + path;
Assert.AreEqual (path, ex.FileName, "#B3");
Assert.IsNull (ex.InnerException, "#B4");
Assert.IsNotNull (ex.Message, "#B5");
@@ -135,8 +140,9 @@ namespace MonoTests.System.IO
[Test]
public void CtorFileNotFoundException_Mode_Truncate ()
{
const string file_name = "thisfileshouldNOTexist.test";
// absolute path
string path = TempFolder + DSC + "thisfileshouldNOTexists.test";
string path = TempFolder + DSC + file_name;
DeleteFile (path);
FileStream stream = null;
try {
@@ -159,14 +165,18 @@ namespace MonoTests.System.IO
// relative path
string orignalCurrentDir = Directory.GetCurrentDirectory ();
Directory.SetCurrentDirectory (TempFolder);
// If TempFolder is a symlink, Mono will follow it and ex.FileName below will contain
// the real directory name, not that of the TempFolder symlink and the test will fail
// (happens e.g. on Android M)
string realTempDir = Directory.GetCurrentDirectory ();
path = realTempDir + DSC + file_name;
try {
stream = new FileStream ("thisfileshouldNOTexists.test", FileMode.Truncate);
stream = new FileStream (file_name, FileMode.Truncate);
Assert.Fail ("#B1");
} catch (FileNotFoundException ex) {
Assert.AreEqual (typeof (FileNotFoundException), ex.GetType (), "#B2");
// under OSX 'var' is a symlink to 'private/var'
if (MacOSX)
path = "/private" + path;
Assert.AreEqual (path, ex.FileName, "#B3");
Assert.IsNull (ex.InnerException, "#B4");
Assert.IsNotNull (ex.Message, "#B5");
@@ -183,8 +193,9 @@ namespace MonoTests.System.IO
[Test]
public void CtorIOException1 ()
{
const string file_name = "thisfileshouldexists.test";
// absolute path
string path = TempFolder + DSC + "thisfileshouldexists.test";
string path = TempFolder + DSC + file_name;
FileStream stream = null;
DeleteFile (path);
try {
@@ -209,11 +220,18 @@ namespace MonoTests.System.IO
// relative path
string orignalCurrentDir = Directory.GetCurrentDirectory ();
Directory.SetCurrentDirectory (TempFolder);
// If TempFolder is a symlink, Mono will follow it and ex.FileName below will contain
// the real directory name, not that of the TempFolder symlink and the test will fail
// (happens e.g. on Android M)
string realTempDir = Directory.GetCurrentDirectory ();
path = realTempDir + DSC + file_name;
try {
stream = new FileStream ("thisfileshouldexists.test", FileMode.CreateNew);
stream = new FileStream (file_name, FileMode.CreateNew);
stream.Close ();
stream = null;
stream = new FileStream ("thisfileshouldexists.test", FileMode.CreateNew);
stream = new FileStream (file_name, FileMode.CreateNew);
Assert.Fail ("#B1");
} catch (IOException ex) {
Assert.AreEqual (typeof (IOException), ex.GetType (), "#B2");
@@ -327,8 +345,14 @@ namespace MonoTests.System.IO
{
string orignalCurrentDir = Directory.GetCurrentDirectory ();
Directory.SetCurrentDirectory (TempFolder);
// If TempFolder is a symlink, Mono will follow it and ex.FileName below will contain
// the real directory name, not that of the TempFolder symlink and the test will fail
// (happens e.g. on Android M)
string realTempDir = Directory.GetCurrentDirectory ();
string relativePath = "DirectoryDoesNotExist" + Path.DirectorySeparatorChar + "file.txt";
string fullPath = Path.Combine (TempFolder, relativePath);
string fullPath = Path.Combine (realTempDir, relativePath);
try {
new FileStream (relativePath, FileMode.Open);
Assert.Fail ("#A1");

View File

@@ -2537,6 +2537,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category ("AndroidNotWorking")] // locks with offsets bigger than Int32.Max don't work on Android
public void Lock_Large ()
{
// note: already worked without HAVE_LARGE_FILE_SUPPORT

View File

@@ -173,9 +173,10 @@ namespace MonoTests.System.IO
Assert.AreEqual ("one", testPath, "Combine #03");
string current = Directory.GetCurrentDirectory ();
bool currentIsDSC = current.Length == 1 && current [0] == DSC;
testPath = Path.Combine (current, "one");
string expected = current + DSC + "one";
string expected = (currentIsDSC ? String.Empty : current) + DSC + "one";
Assert.AreEqual (expected, testPath, "Combine #04");
testPath = Path.Combine ("one", current);
@@ -484,9 +485,9 @@ namespace MonoTests.System.IO
public void GetFullPath ()
{
string current = Directory.GetCurrentDirectory ();
bool currentIsDSC = current.Length == 1 && current [0] == DSC;
string testFullPath = Path.GetFullPath ("foo.txt");
string expected = current + DSC + "foo.txt";
string expected = (currentIsDSC ? String.Empty : current) + DSC + "foo.txt";
Assert.AreEqual (expected, testFullPath, "GetFullPath #01");
testFullPath = Path.GetFullPath ("a//./.././foo.txt");

View File

@@ -1072,18 +1072,7 @@ namespace MonoTests.System.IO
{
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(mem_byteptr,
length, capacity, FileAccess.ReadWrite);
try {
ums.Position = 0x80000000;
Assert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
// MemoryStream length must be non-negative and less than
// 2^31 - 1 - origin
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNotNull (ex.ParamName, "#5");
Assert.AreEqual ("value", ex.ParamName, "#6");
}
ums.Position = 0x80000000;
ums.Close();
}