-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Kim-SSi/main
Add unit test files - UnitTestData
- Loading branch information
Showing
30 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+13.8 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_dither.tif
Binary file not shown.
Binary file added
BIN
+3.91 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_01_threshold.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+24 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_minisblack.tif
Binary file not shown.
Binary file added
BIN
+30.9 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_04_gs_unordered.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+83.7 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_minisblack.tif
Binary file not shown.
Binary file added
BIN
+68.5 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Even/Image_08_gs_unordered.tif
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 added
BIN
+3.98 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_01_threshold.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+24.3 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_minisblack.tif
Binary file not shown.
Binary file added
BIN
+31.1 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_04_gs_unordered.tif
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+83.5 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_minisblack.tif
Binary file not shown.
Binary file added
BIN
+75.9 KB
Wrapper/FreeImage.NET/cs/UnitTestData/Images/Odd/Image_08_gs_unordered.tif
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
153
Wrapper/FreeImage.NET/cs/UnitTestData/MarshallerBug/Bug.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |