-
Notifications
You must be signed in to change notification settings - Fork 774
Expand file tree
/
Copy pathTestCustomMarshal.cs
More file actions
35 lines (30 loc) · 883 Bytes
/
TestCustomMarshal.cs
File metadata and controls
35 lines (30 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using NUnit.Framework;
using Python.Runtime;
namespace Python.EmbeddingTest
{
public class TestCustomMarshal
{
[OneTimeSetUp]
public void SetUp()
{
PythonEngine.Initialize();
}
[OneTimeTearDown]
public void Dispose()
{
PythonEngine.Shutdown();
}
[Test]
public static void GetManagedStringTwice()
{
const string expected = "FooBar";
using var op = Runtime.Runtime.PyString_FromString(expected);
string s1 = Runtime.Runtime.GetManagedString(op.BorrowOrThrow());
string s2 = Runtime.Runtime.GetManagedString(op.Borrow());
Assert.AreEqual(1, Runtime.Runtime.Refcount32(op.Borrow()));
Assert.AreEqual(expected, s1);
Assert.AreEqual(expected, s2);
}
}
}