2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
19 public class SubstringSafeTest : UnitTest
21 public override void Execute(
string method =
null)
24 Describe(
"SubstringSafe(int start, int length)", () =>
26 Describe(
"empty string", () =>
28 Expect(
"".SubstringSafe(0, 1)).ToBeEqual(
"");
31 Describe(
"1 letter", () =>
33 Expect(s.SubstringSafe(0, 1)).ToBeEqual(
"q");
34 Expect(s.SubstringSafe(1, 1)).ToBeEqual(
"w");
35 Expect(s.SubstringSafe(2, 1)).ToBeEqual(
"e");
36 Expect(s.SubstringSafe(3, 1)).ToBeEqual(
"r");
37 Expect(s.SubstringSafe(4, 1)).ToBeEqual(
"t");
38 Expect(s.SubstringSafe(5, 1)).ToBeEqual(
"y");
39 Expect(s.SubstringSafe(6, 1)).ToBeEqual(
"");
42 Describe(
"out of bounds", () =>
44 Expect(s.SubstringSafe(-100, 6)).ToBeEqual(
"");
45 Expect(s.SubstringSafe(100, 10)).ToBeEqual(
"");
46 Expect(s.SubstringSafe(0, 100)).ToBeEqual(
"qwerty");
47 Expect(s.SubstringSafe(-50, 100)).ToBeEqual(
"qwerty");
48 Expect(s.SubstringSafe(0, 6)).ToBeEqual(
"qwerty");
52 Describe(
"SubstringSafe(int start)", () =>
54 Expect(
"".SubstringSafe(0)).ToBeEqual(
"");
55 Expect(
"".SubstringSafe(100)).ToBeEqual(
"");
56 Expect(
"".SubstringSafe(-100)).ToBeEqual(
"");
57 Expect(s.SubstringSafe(-100)).ToBeEqual(
"qwerty");
58 Expect(s.SubstringSafe(0)).ToBeEqual(
"qwerty");
59 Expect(s.SubstringSafe(1)).ToBeEqual(
"werty");
60 Expect(s.SubstringSafe(2)).ToBeEqual(
"erty");
61 Expect(s.SubstringSafe(3)).ToBeEqual(
"rty");
62 Expect(s.SubstringSafe(4)).ToBeEqual(
"ty");
63 Expect(s.SubstringSafe(5)).ToBeEqual(
"y");
64 Expect(s.SubstringSafe(6)).ToBeEqual(
"");
65 Expect(s.SubstringSafe(100)).ToBeEqual(
"");