Skip to content

Commit 8dd97c4

Browse files
committed
Extended Unit tests
All tests successful
1 parent 797c0a3 commit 8dd97c4

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • src/libArgument/libArgument.Tests

src/libArgument/libArgument.Tests/Test.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class GeneralTests
1212
{
1313
public class Options {
1414
[Argument ("", "msg")]
15-
public string Msg;
15+
public string Msg = "Test";
1616

1717
[Switch ("", "enable-log")]
1818
public bool Log;
@@ -24,6 +24,10 @@ public class Options {
2424
[Argument ("f", "float")]
2525
[CastAs (CastingType.Float)]
2626
public float AFloat;
27+
28+
[Argument ("b", "bool")]
29+
[CastAs (CastingType.Boolean)]
30+
public bool ABool;
2731
}
2832

2933
[Test]
@@ -32,6 +36,16 @@ public void TestArgument () {
3236
StringAssert.AreEqualIgnoringCase ("Hello, World!", ArgumentParser.Parse<Options> (args).Msg);
3337
}
3438

39+
[Test]
40+
public void TestDefaultArgument () {
41+
StringAssert.AreEqualIgnoringCase ("Test", ArgumentParser.Parse<Options> (new string[] {}).Msg);
42+
}
43+
44+
[Test]
45+
public void TestDefaultBoolArgument () {
46+
Assert.IsFalse (ArgumentParser.Parse<Options> (new string[] {}).ABool);
47+
}
48+
3549
[Test]
3650
public void TestEmptyArgument () {
3751
var args = new [] { "--msg" };
@@ -46,10 +60,11 @@ public void TestSwitch () {
4660

4761
[Test]
4862
public void TestConversion () {
49-
var args = new [] { "-n", "123", "-f", "3.1416" };
63+
var args = new [] { "-n", "123", "-f", "3.1416", "--bool", "true" };
5064
var options = ArgumentParser.Parse<Options> (args);
5165
Assert.AreEqual (123, options.ANumber);
5266
Assert.AreEqual (3.1416f, options.AFloat);
67+
Assert.That (options.ABool);
5368
}
5469
}
5570
}

0 commit comments

Comments
 (0)