mirror of https://github.com/ppy/SDL3-CS.git
Add tests for binary representation of SDL_bool
This commit is contained in:
parent
9f75280505
commit
03cb53dd11
|
|
@ -14,6 +14,9 @@ namespace SDL.Tests
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
Console.WriteLine($"SDL_FALSE is represented as 0x{SDL_OutOfMemory():X} (expected 0x{SDL_bool.SDL_FALSE:X})");
|
||||||
|
Console.WriteLine($"SDL_TRUE is represented as 0x{SDL_ClearError():X} (expected 0x{SDL_bool.SDL_TRUE:X})");
|
||||||
|
|
||||||
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "null byte \0 in string"u8);
|
SDL_SetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, "null byte \0 in string"u8);
|
||||||
Debug.Assert(SDL_GetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4) == "null byte ");
|
Debug.Assert(SDL_GetHint(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4) == "null byte ");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
// 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 TestSDLBool
|
||||||
|
{
|
||||||
|
private SDL_bool invert(SDL_bool value) => value == SDL_bool.SDL_TRUE ? SDL_bool.SDL_FALSE : SDL_bool.SDL_TRUE;
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFalse()
|
||||||
|
{
|
||||||
|
Assert.That(SDL3.SDL_OutOfMemory(), Is.EqualTo(SDL_bool.SDL_FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTrue()
|
||||||
|
{
|
||||||
|
Assert.That(SDL3.SDL_ClearError(), Is.EqualTo(SDL_bool.SDL_TRUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestStoreLoad([Values] SDL_bool value)
|
||||||
|
{
|
||||||
|
var props = SDL3.SDL_CreateProperties();
|
||||||
|
Assume.That(props, Is.Not.EqualTo(0));
|
||||||
|
|
||||||
|
var ret = SDL3.SDL_SetBooleanProperty(props, "test", value);
|
||||||
|
Assume.That(ret, Is.EqualTo(SDL_bool.SDL_TRUE));
|
||||||
|
|
||||||
|
Assert.That(SDL3.SDL_GetBooleanProperty(props, "test", invert(value)), Is.EqualTo(value));
|
||||||
|
|
||||||
|
SDL3.SDL_DestroyProperties(props);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue