Skip to content

Commit

Permalink
Add unti test files - UnitTestData from http://office.datagis.com/pub…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-SSi committed May 13, 2024
1 parent 0717e93 commit 48ee99a
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
153 changes: 153 additions & 0 deletions Wrapper/FreeImage.NET/cs/UnitTestData/MarshallerBug/Bug.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// This sample code shows a bug in the .NET marshaller.
// Native C++ functions returning a string (char*) sometimes
// are not marshalled correctly throwing an exception.
// This is the reason why the .NET wrapper converts
// the char-pointer manually into a .NET string.

using System;
using System.Text;
using System.Runtime.InteropServices;

public static class FreeImage
{
private const string dllName = "FreeImage.dll";

[DllImport(dllName, EntryPoint = "FreeImage_GetFormatFromFIF")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetFormatFromFIF(int format);

[DllImport(dllName, EntryPoint = "FreeImage_GetFIFExtensionList")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetFIFExtensionList(int format);

[DllImport(dllName, EntryPoint = "FreeImage_GetFIFDescription")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetFIFDescription(int format);

[DllImport(dllName, EntryPoint = "FreeImage_GetFIFRegExpr")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetFIFRegExpr(int format);

[DllImport(dllName, EntryPoint = "FreeImage_GetFIFMimeType")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string GetFIFMimeType(int format);

[DllImport(dllName, EntryPoint = "FreeImage_GetFIFCount")]
public static extern int GetFIFCount();
}

public class Program
{
public static bool[,] getmatrix(int fifCount)
{
bool[,] matrix = new bool[5, fifCount];

int j = 0;

for (int i = 0; i < fifCount; i++)
{
bool success = true;
try
{
FreeImage.GetFormatFromFIF(i);
}
catch
{
success = false;
}
matrix[j, i] = success;
}
j++;

for (int i = 0; i < fifCount; i++)
{
bool success = true;
try
{
FreeImage.GetFIFExtensionList(i);
}
catch
{
success = false;
}
matrix[j, i] = success;
}
j++;

for (int i = 0; i < fifCount; i++)
{
bool success = true;
try
{
FreeImage.GetFIFDescription(i);
}
catch
{
success = false;
}
matrix[j, i] = success;
}
j++;

for (int i = 0; i < fifCount; i++)
{
bool success = true;
try
{
FreeImage.GetFIFRegExpr(i);
}
catch
{
success = false;
}
matrix[j, i] = success;
}
j++;

for (int i = 0; i < fifCount; i++)
{
bool success = true;
try
{
FreeImage.GetFIFMimeType(i);
}
catch
{
success = false;
}
matrix[j, i] = success;
}

return matrix;
}

public static void Main()
{
int fifCount = FreeImage.GetFIFCount();
bool[,] matrix = getmatrix(fifCount);

Console.Clear();
Console.WriteLine("1: GetFormatFromFIF");
Console.WriteLine("2: GetFIFExtensionList");
Console.WriteLine("3: GetFIFDescription");
Console.WriteLine("4: GetFIFRegExpr");
Console.WriteLine("5: GetFIFMimeType");
Console.Write(Environment.NewLine);

Console.Write("FIF:\t");
for (int x = 1; x < 6; x++)
Console.Write("{0}:\t", x);

Console.Write(Environment.NewLine);

for (int k = 0; k < fifCount; k++)
{
Console.Write("{0}:\t", k);
for (int l = 0; l < 5; l++)
{
Console.Write(matrix[l, k] ? "1\t" : "0\t");
}
Console.Write(Environment.NewLine);
}
}
}
14 changes: 14 additions & 0 deletions Wrapper/FreeImage.NET/cs/UnitTestData/NUnit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
NUnit 2.x is needed for FreeImage .NET wrapper unit tests. It can be
downloaded from http://www.nunit.org/

After installing NUnit, double click on the NUnit project file
FreeImage.NET.nunit located in the FreeImage .NET wrapper Source folder
to load the project.

The FreeImage .NET wrapper unit test project UnitTest.csproj, located
under Source\UnitTest, must be compiled in 'Debug' mode prior to opening
the NUnit project.

The FreeImage .NET wrapper unit test project UnitTest.csproj currently
relies on the FreeImage .NET wrapper single source file, created by the
Source File Merger, located in the Source\SourceFileMerger folder.

0 comments on commit 48ee99a

Please sign in to comment.