GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pythonnet/src/embed_tests/TestPySequence.cs at master · pythonnet/pythonnet

Expand file tree

/

TestPySequence.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
83 lines (66 loc) · 2.12 KB
/

TestPySequence.cs

Copy path

File metadata and controls

83 lines (66 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using NUnit.Framework;
using Python.Runtime;
namespace Python.EmbeddingTest
{
public class TestPySequence
{
[Test]
public void TestIsSequenceTrue()
{
var t = new PyString("FooBar");
Assert.True(PySequence.IsSequenceType(t));
}
[Test]
public void TestIsSequenceFalse()
{
var t = new PyInt(5);
Assert.False(PySequence.IsSequenceType(t));
}
[Test]
public void TestGetSlice()
{
var t = new PyString("FooBar");
PyObject s = t.GetSlice(0, 3);
Assert.That(s.ToString(), Is.EqualTo("Foo"));
PyObject s2 = t.GetSlice(3, 6);
Assert.That(s2.ToString(), Is.EqualTo("Bar"));
PyObject s3 = t.GetSlice(0, 6);
Assert.That(s3.ToString(), Is.EqualTo("FooBar"));
PyObject s4 = t.GetSlice(0, 12);
Assert.That(s4.ToString(), Is.EqualTo("FooBar"));
}
[Test]
public void TestConcat()
{
var t1 = new PyString("Foo");
var t2 = new PyString("Bar");
PyObject actual = t1.Concat(t2);
Assert.That(actual.ToString(), Is.EqualTo("FooBar"));
}
[Test]
public void TestRepeat()
{
var t1 = new PyString("Foo");
PyObject actual = t1.Repeat(3);
Assert.That(actual.ToString(), Is.EqualTo("FooFooFoo"));
actual = t1.Repeat(-3);
Assert.That(actual.ToString(), Is.EqualTo(""));
}
[Test]
public void TestContains()
{
var t1 = new PyString("FooBar");
Assert.True(t1.Contains(new PyString("a")));
Assert.False(t1.Contains(new PyString("z")));
}
[Test]
public void TestIndex()
{
var t1 = new PyString("FooBar");
Assert.That(t1.Index32(new PyString("a")), Is.EqualTo(4));
Assert.That(t1.Index64(new PyString("r")), Is.EqualTo(5L));
Assert.That(t1.Index(new PyString("z")), Is.EqualTo(-(nint)1));
}
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.