[main] Partial fix for AVAudioEngine.Connect(input, sink, format) crash when format == null (#9410)
* partial fix for https://github.com/xamarin/xamarin-macios/issues/9267 * simplify notequals * add monotouch-test case * add more using per manuel's feedback Co-authored-by: Whitney Schmidt <whschm@microsoft.com>
This commit is contained in:
Родитель
558af9612a
Коммит
2a569e6274
|
@ -21,12 +21,16 @@ namespace AVFoundation {
|
|||
public partial class AVAudioFormat {
|
||||
public static bool operator == (AVAudioFormat a, AVAudioFormat b)
|
||||
{
|
||||
if ((object) a == (object) b)
|
||||
return true;
|
||||
if ((object) a == null ^ (object) b == null)
|
||||
return false;
|
||||
return a.Equals (b);
|
||||
}
|
||||
|
||||
public static bool operator != (AVAudioFormat a, AVAudioFormat b)
|
||||
{
|
||||
return !a.Equals (b);
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// Unit test for AVAudioFormat
|
||||
// Authors:
|
||||
// Whitney Schmidt (whschm@microsoft.com)
|
||||
// Copyright 2020 Microsoft Corp.
|
||||
|
||||
using System;
|
||||
using Foundation;
|
||||
using AVFoundation;
|
||||
using NUnit.Framework;
|
||||
namespace MonoTouchFixtures.AVFoundation {
|
||||
|
||||
[TestFixture]
|
||||
[Preserve (AllMembers = true)]
|
||||
public class AVAudioFormatTest {
|
||||
|
||||
[Test]
|
||||
public void TestEqualOperatorSameInstace ()
|
||||
{
|
||||
using (var format = new AVAudioFormat ())
|
||||
Assert.IsTrue (format == format, "format == format");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEqualOperatorNull ()
|
||||
{
|
||||
using (var format = new AVAudioFormat ())
|
||||
{
|
||||
Assert.IsFalse (format == null, "format == null");
|
||||
Assert.IsFalse (null == format, "null == format");
|
||||
}
|
||||
using (AVAudioFormat nullFormat = null)
|
||||
{
|
||||
Assert.IsTrue (nullFormat == null, "nullFormat == null");
|
||||
Assert.IsTrue (null == nullFormat, "null == nullFormat");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotEqualOperatorNull ()
|
||||
{
|
||||
using (var format = new AVAudioFormat ())
|
||||
{
|
||||
Assert.IsTrue (format != null, "format != null");
|
||||
Assert.IsTrue (null != format, "null != format");
|
||||
}
|
||||
using (AVAudioFormat nullFormat = null)
|
||||
{
|
||||
Assert.IsFalse (nullFormat != null, "nullFormat != null");
|
||||
Assert.IsFalse (null != nullFormat, "null != nullFormat");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче