-
Notifications
You must be signed in to change notification settings - Fork 29
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 #982 from gircore/gvalue-support-enum
GValue: Support setting an enumeration / bitfield
- Loading branch information
Showing
7 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
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
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,24 @@ | ||
#include "girtest-enum-tester.h" | ||
|
||
/** | ||
* GirTestEnumTester: | ||
* | ||
* Contains functions for testing enumerations. | ||
*/ | ||
|
||
struct _GirTestEnumTester | ||
{ | ||
GObject parent_instance; | ||
}; | ||
|
||
G_DEFINE_TYPE(GirTestEnumTester, girtest_enum_tester, G_TYPE_OBJECT) | ||
|
||
static void | ||
girtest_enum_tester_init(GirTestEnumTester *value) | ||
{ | ||
} | ||
|
||
static void | ||
girtest_enum_tester_class_init(GirTestEnumTesterClass *class) | ||
{ | ||
} |
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,25 @@ | ||
#pragma once | ||
|
||
#include <glib-object.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
/** | ||
* EnumTesterSimpleEnum: | ||
* @A: 1 | ||
* @B: 2 | ||
* @C: 3 | ||
* | ||
* Enum to test bindings | ||
*/ | ||
typedef enum { | ||
SIMPLE_ENUM_A = 1, | ||
SIMPLE_ENUM_B = 2, | ||
SIMPLE_ENUM_C = 3 | ||
} GirTestEnumTesterSimpleEnum; | ||
|
||
#define GIRTEST_TYPE_ENUM_TESTER girtest_enum_tester_get_type() | ||
|
||
G_DECLARE_FINAL_TYPE(GirTestEnumTester, girtest_enum_tester, GIRTEST, ENUM_TESTER, GObject) | ||
|
||
G_END_DECLS |
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
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
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
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,19 @@ | ||
using FluentAssertions; | ||
using GObject; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GirTest.Tests; | ||
|
||
[TestClass, TestCategory("BindingTest")] | ||
public class EnumerationTest : Test | ||
{ | ||
[TestMethod] | ||
public void CanBeUsedInGValue() | ||
{ | ||
var e = EnumTesterSimpleEnum.A; | ||
var value = new Value(Type.Enum); | ||
value.Set(e); | ||
var result = value.Extract<EnumTesterSimpleEnum>(); | ||
result.Should().Be(e); | ||
} | ||
} |