mirror of https://github.com/ppy/SDL3-CS.git
Merge pull request #265 from Susko3/cleanup-error
Add tests for `SDL_error.cs` and ensure u8 constants are explicitly null-terminated
This commit is contained in:
commit
4988d55819
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace SDL.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestError
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void TestUnsupported()
|
||||||
|
{
|
||||||
|
Assert.That((bool)SDL3.SDL_Unsupported(), Is.False);
|
||||||
|
Assert.That(SDL3.SDL_GetError(), Is.EqualTo("That operation is not supported"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInvalidParam()
|
||||||
|
{
|
||||||
|
Assert.That((bool)SDL3.SDL_InvalidParamError("test"), Is.False);
|
||||||
|
Assert.That(SDL3.SDL_GetError(), Is.EqualTo("Parameter 'test' is invalid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,14 +8,14 @@ namespace SDL
|
||||||
[Macro]
|
[Macro]
|
||||||
public static unsafe SDLBool SDL_Unsupported()
|
public static unsafe SDLBool SDL_Unsupported()
|
||||||
{
|
{
|
||||||
fixed (byte* fmt = "That operation is not supported"u8)
|
fixed (byte* fmt = "That operation is not supported\0"u8)
|
||||||
return SDL_SetError(fmt, __arglist());
|
return SDL_SetError(fmt, __arglist());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Macro]
|
[Macro]
|
||||||
public static unsafe SDLBool SDL_InvalidParamError([NativeTypeName("const char *")] byte* param)
|
public static unsafe SDLBool SDL_InvalidParamError([NativeTypeName("const char *")] byte* param)
|
||||||
{
|
{
|
||||||
fixed (byte* fmt = "Parameter '%s' is invalid"u8)
|
fixed (byte* fmt = "Parameter '%s' is invalid\0"u8)
|
||||||
return SDL_SetError(fmt, __arglist(param));
|
return SDL_SetError(fmt, __arglist(param));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue