Skip to content

Commit

Permalink
Merge pull request #25 from SimonCahill/add-missing-tests
Browse files Browse the repository at this point in the history
Added some missing tests
  • Loading branch information
SimonCahill committed Mar 14, 2023
2 parents 417eb47 + 366d418 commit 5a34a66
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions getopt.net.tests/GetOptTests_Inherited.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,72 @@ public class GetOptTests_Inherited: GetOpt {
Assert.AreEqual("arg", optVal);
}

[TestMethod]
public void TestMustStopParsing() {
m_currentIndex = 0;
ShortOpts = "+abcde:";
AppArgs = new[] { "-abcdeTEST" };

Assert.IsTrue(MustStopParsing());
}

[TestMethod]
public void TestMustReturnChar1() {
m_currentIndex = 0;
ShortOpts = "-abcde:";
AppArgs = new[] { "-abcdeTEST" };

Assert.IsTrue(MustReturnChar1());
}

[TestMethod]
public void TestArgumentSplitter() {
const string TestString1 = "--test bla";
const string TestString2 = "-test bla";
const string TestString3 = "test bla";
const string TestString4 = "/test bla";
const string TestString5 = "--test=bla";
const string TestString6 = "-test=bla";
const string TestString7 = "test=bla";
const string TestString8 = "/test=bla";

Assert.IsTrue(ArgumentSplitter().IsMatch(TestString1));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString2));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString3));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString4));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString5));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString6));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString7));
Assert.IsTrue(ArgumentSplitter().IsMatch(TestString8));

Assert.IsTrue(ArgumentSplitter().Matches(TestString1).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString2).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString3).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString4).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString5).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString6).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString7).Count == 1);
Assert.IsTrue(ArgumentSplitter().Matches(TestString8).Count == 1);

Assert.AreEqual(3, ArgumentSplitter().Split(TestString1).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString2).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString3).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString4).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString5).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString6).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString7).Length);
Assert.AreEqual(3, ArgumentSplitter().Split(TestString8).Length);

Assert.AreEqual(2, ArgumentSplitter().Split(TestString1).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString2).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString3).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString4).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString5).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString6).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString7).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
Assert.AreEqual(2, ArgumentSplitter().Split(TestString8).Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x) && x != "=").Count());
}

}

}

0 comments on commit 5a34a66

Please sign in to comment.