mirror of https://github.com/dahall/Vanara.git
Added unit test and corrected return values in Lz32
parent
509ae2758a
commit
c37ef68f8b
|
@ -404,7 +404,7 @@ namespace Vanara.PInvoke
|
|||
// https://docs.microsoft.com/en-us/windows/win32/api/lzexpand/nf-lzexpand-lzinit INT LZInit( INT hfSource );
|
||||
[DllImport(Lib_Lz32, SetLastError = false, ExactSpelling = true)]
|
||||
[PInvokeData("lzexpand.h", MSDNShortId = "NF:lzexpand.LZInit")]
|
||||
public static extern int LZInit(/*HFILE*/ int hfSource);
|
||||
public static extern HLZFILE LZInit(/*HFILE*/ int hfSource);
|
||||
|
||||
/// <summary>Creates, opens, reopens, or deletes the specified file.</summary>
|
||||
/// <param name="lpFileName">The name of the file.</param>
|
||||
|
@ -587,7 +587,7 @@ namespace Vanara.PInvoke
|
|||
// lpReOpenBuf, WORD wStyle );
|
||||
[DllImport(Lib_Lz32, SetLastError = false, CharSet = CharSet.Auto)]
|
||||
[PInvokeData("lzexpand.h", MSDNShortId = "NF:lzexpand.LZOpenFileA")]
|
||||
public static extern int LZOpenFile([In, MarshalAs(UnmanagedType.LPTStr)] string lpFileName, ref OFSTRUCT lpReOpenBuf, LZ_OF wStyle);
|
||||
public static extern HLZFILE LZOpenFile([In, MarshalAs(UnmanagedType.LPTStr)] string lpFileName, ref OFSTRUCT lpReOpenBuf, LZ_OF wStyle);
|
||||
|
||||
/// <summary>Reads (at most) the specified number of bytes from a file and copies them into a buffer.</summary>
|
||||
/// <param name="hFile">A handle to the file.</param>
|
||||
|
@ -767,7 +767,7 @@ namespace Vanara.PInvoke
|
|||
|
||||
/// <summary>Provides a handle to a compressed file.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HLZFILE : IHandle
|
||||
public readonly struct HLZFILE : IHandle
|
||||
{
|
||||
private readonly int handle;
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>UnitTest.PInvoke.Lz32</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\PInvoke\Lz32\Vanara.PInvoke.Lz32.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,19 @@
|
|||
using NUnit.Framework;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Vanara.PInvoke.Lz32;
|
||||
|
||||
namespace Vanara.PInvoke.Tests;
|
||||
|
||||
[TestFixture]
|
||||
public class Lz32Tests
|
||||
{
|
||||
[Test]
|
||||
public void Test()
|
||||
{
|
||||
OFSTRUCT openStruct = new() { cBytes = (byte)Marshal.SizeOf(typeof(OFSTRUCT)) };
|
||||
var hSrc = LZOpenFile(@"C:\Windows\IME\IMETC\HELP\IMTCEN14.CHM", ref openStruct, LZ_OF.OF_READ);
|
||||
Assert.That((int)hSrc, Is.GreaterThanOrEqualTo(0));
|
||||
openStruct.WriteValues();
|
||||
LZClose(hSrc);
|
||||
}
|
||||
}
|
22
Vanara.sln
22
Vanara.sln
|
@ -414,7 +414,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreAudio", "UnitTests\PInv
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.CoreAudio", "PInvoke\CoreAudio\Vanara.PInvoke.CoreAudio.csproj", "{D3085D14-8745-4174-8D16-102615E2CE60}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.Avrt", "PInvoke\Avrt\Vanara.PInvoke.Avrt.csproj", "{20C67C75-BCD0-4AFC-8C69-32C11450D7FA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.Avrt", "PInvoke\Avrt\Vanara.PInvoke.Avrt.csproj", "{20C67C75-BCD0-4AFC-8C69-32C11450D7FA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lz32", "UnitTests\PInvoke\Lz32\Lz32.csproj", "{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -3649,6 +3651,23 @@ Global
|
|||
{20C67C75-BCD0-4AFC-8C69-32C11450D7FA}.Release|x64.Build.0 = Release|x64
|
||||
{20C67C75-BCD0-4AFC-8C69-32C11450D7FA}.Release|x86.ActiveCfg = Release|x86
|
||||
{20C67C75-BCD0-4AFC-8C69-32C11450D7FA}.Release|x86.Build.0 = Release|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|x64.Build.0 = Debug|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Debug|x86.Build.0 = Debug|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|Any CPU.ActiveCfg = DebugNoTests|Any CPU
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|Any CPU.Build.0 = DebugNoTests|Any CPU
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|x64.ActiveCfg = DebugNoTests|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|x64.Build.0 = DebugNoTests|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|x86.ActiveCfg = DebugNoTests|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.DebugNoTests|x86.Build.0 = DebugNoTests|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Release|x64.ActiveCfg = Release|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Release|x64.Build.0 = Release|x64
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Release|x86.ActiveCfg = Release|x86
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -3836,6 +3855,7 @@ Global
|
|||
{B5EBAECC-D3F1-4388-8A2B-634F5A0014B9} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
|
||||
{D3085D14-8745-4174-8D16-102615E2CE60} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
|
||||
{20C67C75-BCD0-4AFC-8C69-32C11450D7FA} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
|
||||
{3A6782D5-E72D-4546-81D6-EBA19A08D9E3} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}
|
||||
|
|
Loading…
Reference in New Issue