-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "girtest-string-array-tester.h" | ||
|
||
/** | ||
* GirTestStringArrayTester: | ||
* | ||
* Contains functions for testing bindings with string arrays. | ||
*/ | ||
|
||
const char* data[] = { "FOO", "BAR", NULL }; | ||
|
||
struct _GirTestStringArrayTester | ||
{ | ||
GObject parent_instance; | ||
}; | ||
|
||
G_DEFINE_TYPE(GirTestStringArrayTester, girtest_string_array_tester, G_TYPE_OBJECT) | ||
|
||
static void | ||
girtest_string_array_tester_init(GirTestStringArrayTester *value) | ||
{ | ||
} | ||
|
||
static void | ||
girtest_string_array_tester_class_init(GirTestStringArrayTesterClass *class) | ||
{ | ||
} | ||
|
||
/** | ||
* girtest_string_array_tester_return_transfer_none: | ||
* | ||
* Returns an array. | ||
* | ||
* Returns: (transfer none): The array | ||
*/ | ||
const char** girtest_string_array_tester_return_transfer_none() | ||
{ | ||
return data; | ||
} | ||
|
||
/** | ||
* girtest_string_array_tester_return_element_parameter_null_terminated_transfer_none: | ||
* @data: (array zero-terminated=1) (element-type utf8) (transfer none): Array | ||
* @position: The index to return | ||
* | ||
* Returns the string at the given position. | ||
* | ||
* Returns: (transfer full): The string of the array from the given position | ||
*/ | ||
gchar* girtest_string_array_tester_return_element_parameter_null_terminated_transfer_none(const gchar** data, int position) | ||
{ | ||
return g_strdup(data[position]); | ||
} |
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 @@ | ||
#pragma once | ||
|
||
#include <glib-object.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define GIRTEST_TYPE_STRING_ARRAY_TESTER girtest_string_array_tester_get_type() | ||
|
||
G_DECLARE_FINAL_TYPE(GirTestStringArrayTester, girtest_string_array_tester, | ||
GIRTEST, STRING_ARRAY_TESTER, GObject) | ||
|
||
const char** girtest_string_array_tester_return_transfer_none(); | ||
gchar* girtest_string_array_tester_return_element_parameter_null_terminated_transfer_none(const gchar** data, int position); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GirTest.Tests; | ||
|
||
[TestClass, TestCategory("BindingTest")] | ||
public class StringArrayTest : Test | ||
{ | ||
|
||
[TestMethod] | ||
public void ReturnNullTerminatedStringArrayTransferNone() | ||
{ | ||
var array = new [] { "FOO", "BAR" }; | ||
Check warning on line 13 in src/Tests/Libs/GirTest-0.1.Tests/StringArrayTest.cs GitHub Actions / Build (Linux)
|
||
StringArrayTester.ReturnTransferNone().Should().BeEquivalentTo(array); | ||
} | ||
|
||
[TestMethod] | ||
public void ParameterNullTerminatedStringArrayTransferNone() | ||
{ | ||
var array = new [] { "FOO", "BAR" }; | ||
Check warning on line 20 in src/Tests/Libs/GirTest-0.1.Tests/StringArrayTest.cs GitHub Actions / Build (Linux)
|
||
StringArrayTester.ReturnElementParameterNullTerminatedTransferNone(array, 0).Should().Be(array[0]); | ||
StringArrayTester.ReturnElementParameterNullTerminatedTransferNone(array, 1).Should().Be(array[1]); | ||
} | ||
} |