Skip to content

Commit

Permalink
Miscellaneous formatting cleanup to the NativeLibrary tests (dotnet#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeFlux authored and AaronRobinsonMSFT committed Nov 8, 2019
1 parent 4ef94ad commit 2362662
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions tests/src/Interop/NativeLibrary/NativeLibraryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,33 +241,32 @@ static TestResult Run (Func<TestResult> test)
{
result = test();
}
catch (ArgumentNullException e)
catch (ArgumentNullException)
{
return TestResult.ArgumentNull;
return TestResult.ArgumentNull;
}
catch (ArgumentException e)
catch (ArgumentException)
{
return TestResult.ArgumentBad;
}
catch (DllNotFoundException e)
catch (DllNotFoundException)
{
return TestResult.DllNotFound;
}
catch (BadImageFormatException e)
catch (BadImageFormatException)
{
return TestResult.BadImage;
}
catch (InvalidOperationException e)
catch (InvalidOperationException)
{
return TestResult.InvalidOperation;
}
catch (EntryPointNotFoundException e)
catch (EntryPointNotFoundException)
{
return TestResult.EntryPointNotFound;
}
catch (Exception e)
catch (Exception)
{
//Console.WriteLine(e.ToString());
return TestResult.GenericException;
}

Expand All @@ -283,7 +282,7 @@ static TestResult LoadLibrarySimple(string libPath)
TestResult result = Run(() => {
handle = NativeLibrary.Load(libPath);
if (handle == IntPtr.Zero)
return TestResult.ReturnNull;
return TestResult.ReturnNull;
return TestResult.Success;
});

Expand All @@ -300,10 +299,10 @@ static TestResult TryLoadLibrarySimple(string libPath)

TestResult result = Run(() => {
bool success = NativeLibrary.TryLoad(libPath, out handle);
if(!success)
if (!success)
return TestResult.ReturnFailure;
if (handle == null)
return TestResult.ReturnNull;
if (handle == IntPtr.Zero)
return TestResult.ReturnNull;
return TestResult.Success;
});

Expand All @@ -322,7 +321,7 @@ static TestResult LoadLibraryAdvanced(string libName, Assembly assembly, DllImpo
TestResult result = Run(() => {
handle = NativeLibrary.Load(libName, assembly, searchPath);
if (handle == IntPtr.Zero)
return TestResult.ReturnNull;
return TestResult.ReturnNull;
return TestResult.Success;
});

Expand All @@ -340,9 +339,9 @@ static TestResult TryLoadLibraryAdvanced(string libName, Assembly assembly, DllI
TestResult result = Run(() => {
bool success = NativeLibrary.TryLoad(libName, assembly, searchPath, out handle);
if (!success)
return TestResult.ReturnFailure;
return TestResult.ReturnFailure;
if (handle == IntPtr.Zero)
return TestResult.ReturnNull;
return TestResult.ReturnNull;
return TestResult.Success;
});

Expand All @@ -367,8 +366,8 @@ static TestResult GetLibraryExport(IntPtr handle, string name)

return Run(() => {
IntPtr address = NativeLibrary.GetExport(handle, name);
if (address == null)
return TestResult.ReturnNull;
if (address == IntPtr.Zero)
return TestResult.ReturnNull;
if (RunExportedFunction(address, 1, 1) != 2)
return TestResult.IncorrectEvaluation;
return TestResult.Success;
Expand All @@ -383,9 +382,9 @@ static TestResult TryGetLibraryExport(IntPtr handle, string name)
IntPtr address = IntPtr.Zero;
bool success = NativeLibrary.TryGetExport(handle, name, out address);
if (!success)
return TestResult.ReturnFailure;
if (address == null)
return TestResult.ReturnNull;
return TestResult.ReturnFailure;
if (address == IntPtr.Zero)
return TestResult.ReturnNull;
if (RunExportedFunction(address, 1, 1) != 2)
return TestResult.IncorrectEvaluation;
return TestResult.Success;
Expand Down

0 comments on commit 2362662

Please sign in to comment.