-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStringPivotTests.cs
126 lines (110 loc) · 4.88 KB
/
StringPivotTests.cs
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System.Collections.Generic;
using System.Linq;
using Xunit;
using static MySQLCLRFunctions.StringPivot;
namespace MySQLCLRFunctions.Tests
{
public class StringPivotTests
{
[Fact]
public void MatchesXTest()
{
const string pattern = @"\((.*?)\)";
const string input = "203-393-4949 (cell)";
string validoutput = "cell";
var output = ((IEnumerable<MatchesRecord>)MatchesX(input, pattern)).ToArray()[0].capturedMatch;
Assert.Equal(expected: validoutput, actual: output);
}
[Fact]
public void PiecesWithContextXTest()
{
const string pattern = "[ ]";
const string input = "input this";
const string validoutput = "input";
var unformed_output = PiecesWithContextX(input, pattern);
Assert.IsNotType<string>(unformed_output);
var staged_output = ((IEnumerable<PiecesWithContextRecord>)unformed_output);
Assert.NotNull(staged_output);
var arrayed_output = staged_output.ToArray();
Assert.Equal(expected: 2, actual: arrayed_output.Count());
var output = arrayed_output[0].piece;
Assert.Equal(expected: validoutput, actual: output);
}
[Fact]
public void PiecesXTest()
{
var pieces = PiecesX("This is input", "\b");
Assert.NotNull(pieces);
}
[CountTest]
[Fact]
public void PiecesXTestCount()
{
var pieces = (string[])PiecesX("This is input", " ");
Assert.Equal(expected: 3, pieces.Length);
}
[PositiveTest]
[Fact]
public void PiecesXTestFirst()
{
var pieces = (string[])PiecesX("This is input", " ");
Assert.Equal(expected: "This", pieces[0]);
}
[Fact]
public void PiecesWithMatchesXTest()
{
var input = "Joan Joyce Julia June Karen Katherine (Kathy) Laura Louise Marilyn Mary Moira Molly Monica Nancy Natalie Norma Pamela (Pam) Patricia (Pat) Paula Ruth Sally Sarah Sophia Susan (Sue) Teresa (Terry) Valerie Veronica Vivian Vickie Wanda Wilma Yvonne";
IEnumerable<PiecesWithMatchesRecord> pieces = (IEnumerable<PiecesWithMatchesRecord>)PiecesWithMatchesX(input, @"(\([^)]+\)|\w+)");
foreach (PiecesWithMatchesRecord piece in pieces.Take(1))
Assert.Equal(expected: "Joan", actual: piece.piece);
}
[Fact]
public void PiecesWithMatchesXTest2()
{
var input = "Joan Joyce Julia June Karen Katherine (Kathy) Laura Louise Marilyn Mary Moira Molly Monica Nancy Natalie Norma Pamela (Pam) Patricia (Pat) Paula Ruth Sally Sarah Sophia Susan (Sue) Teresa (Terry) Valerie Veronica Vivian Vickie Wanda Wilma Yvonne";
IEnumerable<PiecesWithMatchesRecord> pieces = (IEnumerable<PiecesWithMatchesRecord>)PiecesWithMatchesX(input, @"(\([^)]+\)|\w+)");
foreach (PiecesWithMatchesRecord piece in pieces.Skip(1).Take(1))
Assert.Equal(expected: "Joyce", actual: piece.piece);
}
[Fact]
public void PiecesWithMatchesXTest3()
{
var input = "Joan Joyce Julia June Karen Katherine (Kathy) Laura Louise Marilyn Mary Moira Molly Monica Nancy Natalie Norma Pamela (Pam) Patricia (Pat) Paula Ruth Sally Sarah Sophia Susan (Sue) Teresa (Terry) Valerie Veronica Vivian Vickie Wanda Wilma Yvonne";
IEnumerable<PiecesWithMatchesRecord> pieces = (IEnumerable<PiecesWithMatchesRecord>)PiecesWithMatchesX(input, @"(\([^)]+\)|\w+)");
foreach (PiecesWithMatchesRecord piece in pieces.Skip(6).Take(1))
Assert.Equal(expected: "(Kathy)", actual: piece.piece);
}
[Fact]
public void GetWordsTest()
{
const string input = "input";
const string validoutput = input + "not implemented";
var output = "not implemented yet";
Assert.Equal(expected: validoutput, output);
}
[Fact]
public void SplitTest()
{
const string input = "input";
const string validoutput = input + "not implemented";
var output = "not implemented yet";
Assert.Equal(expected: validoutput, output);
}
[Fact]
public void KeyValuePairsWithMultiValuesTest()
{
const string input = "input";
const string validoutput = input + "not implemented";
var output = "not implemented yet";
Assert.Equal(expected: validoutput, output);
}
[Fact]
public void CapturesTest()
{
const string input = "input";
const string validoutput = input + "not implemented";
var output = "not implemented yet";
Assert.Equal(expected: validoutput, output);
}
}
}