Skip to content

Commit 16c1c42

Browse files
committed
Use conventional naming for consts
1 parent fa05067 commit 16c1c42

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/DocoptNet/Internals/Option.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override string ToString()
3434
return $"Option({ShortName},{LongName},{ArgCount},{Value})";
3535
}
3636

37-
const string DESC_SEPARATOR = " ";
37+
const string DescSeparator = " ";
3838

3939
static readonly char[] OptionDelimiters = { ' ', '\t', ',', '=' };
4040

@@ -46,7 +46,7 @@ public static Option Parse(string optionDescription)
4646
string longName = null;
4747
var argCount = 0;
4848
var value = ArgValue.False;
49-
var (options, _, description) = optionDescription.Trim().Partition(DESC_SEPARATOR);
49+
var (options, _, description) = optionDescription.Trim().Partition(DescSeparator);
5050
foreach (var s in options.Split(OptionDelimiters, StringSplitOptions.RemoveEmptyEntries))
5151
{
5252
if (s.StartsWith("--"))

tests/DocoptNet.Tests/Assumptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ public class Assumptions
1212
[Test]
1313
public void String_Split_with_no_args_should_split_on_white_space()
1414
{
15-
const string TEST_STRING = "first second\tthird\nfourth \n\t\ffifth";
16-
var s1 = TEST_STRING.Split();
15+
const string testString = "first second\tthird\nfourth \n\t\ffifth";
16+
var s1 = testString.Split();
1717
Assert.AreEqual(8, s1.Length);
18-
var s2 = TEST_STRING.Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
18+
var s2 = testString.Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
1919
Assert.AreEqual(5, s2.Length);
2020
}
2121
}

tests/DocoptNet.Tests/DocoptTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Match_opt_and_arg()
8484
Assert.AreEqual(expected, actual);
8585
}
8686

87-
const string DOC = @"Usage: prog [-vqr] [FILE]
87+
const string Doc = @"Usage: prog [-vqr] [FILE]
8888
prog INPUT OUTPUT
8989
prog --help
9090
@@ -108,7 +108,7 @@ public void Match_one_opt_with_arg()
108108
{"INPUT", default},
109109
{"OUTPUT", default}
110110
};
111-
var actual = new Docopt().Apply(DOC, "-v file.py");
111+
var actual = new Docopt().Apply(Doc, "-v file.py");
112112
Assert.AreEqual(expected, actual);
113113
}
114114

@@ -125,20 +125,20 @@ public void Match_one_opt_only()
125125
{"INPUT", default},
126126
{"OUTPUT", default}
127127
};
128-
var actual = new Docopt().Apply(DOC, "-v");
128+
var actual = new Docopt().Apply(Doc, "-v");
129129
Assert.AreEqual(expected, actual);
130130
}
131131

132132
[Test]
133133
public void No_match()
134134
{
135-
Assert.Throws<DocoptInputErrorException>(() => new Docopt().Apply(DOC, "-v input.py output.py"));
135+
Assert.Throws<DocoptInputErrorException>(() => new Docopt().Apply(Doc, "-v input.py output.py"));
136136
}
137137

138138
[Test]
139139
public void Non_existent_long()
140140
{
141-
Assert.Throws<DocoptInputErrorException>(() => new Docopt().Apply(DOC, "--fake"));
141+
Assert.Throws<DocoptInputErrorException>(() => new Docopt().Apply(Doc, "--fake"));
142142
}
143143

144144
[Test]
@@ -152,7 +152,7 @@ public void Should_exit_error_code_1()
152152
message = e.Message;
153153
errorCode = e.ErrorCode;
154154
};
155-
d.Apply(DOC, "--fake", exit:true);
155+
d.Apply(Doc, "--fake", exit:true);
156156
StringAssert.StartsWith("Usage", message);
157157
Assert.AreEqual(1, errorCode, "Should exit with error code 1 when exit=true and invalid args provided");
158158
}
@@ -168,7 +168,7 @@ public void Display_help()
168168
message = e.Message;
169169
errorCode = e.ErrorCode;
170170
};
171-
d.Apply(DOC, "--help");
171+
d.Apply(Doc, "--help");
172172
StringAssert.StartsWith("Usage", message);
173173
Assert.AreEqual(0, errorCode);
174174
}

tests/DocoptNet.Tests/ParseDefaultsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class ParseDefaultsTests
88
[Test]
99
public void Test_parse_defaults()
1010
{
11-
const string DOC = @"usage: prog
11+
const string doc = @"usage: prog
1212
Options:
1313
-h, --help Print help message.
1414
-o FILE Output file.
@@ -17,7 +17,7 @@ public void Test_parse_defaults()
1717

1818
var expected = new Option[]
1919
{new Option("-h", "--help"), new Option("-o", null, 1), new Option(null, "--verbose")};
20-
Assert.AreEqual(expected, Docopt.ParseDefaults(DOC));
20+
Assert.AreEqual(expected, Docopt.ParseDefaults(doc));
2121
}
2222

2323
[Test]

tests/DocoptNet.Tests/UsageTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ public class UsageTests
99
[Test]
1010
public void Test_formal_usage()
1111
{
12-
const string DOC =
12+
const string doc =
1313
"Usage: prog [-hv] ARG\r\n" +
1414
" prog N M\r\n" +
1515
"\r\n" +
1616
" prog is a program.";
17-
var usage = Docopt.ParseSection("usage:", DOC).First();
17+
var usage = Docopt.ParseSection("usage:", doc).First();
1818
Assert.AreEqual("Usage: prog [-hv] ARG\r\n prog N M", usage);
1919
Assert.AreEqual("( [-hv] ARG ) | ( N M )", Docopt.FormalUsage(usage));
2020
}
2121
[Test]
2222
public void Should_parse_usage_section_correctly()
2323
{
24-
const string USAGE = @"usage: this
24+
const string usage = @"usage: this
2525
2626
usage:hai
2727
usage: this that
@@ -60,7 +60,7 @@ public void Should_parse_usage_section_correctly()
6060
"usage:\r\n\ttoo\r\n\ttar",
6161
"Usage: eggs spam",
6262
"usage: pit stop"
63-
}, Docopt.ParseSection("usage:", USAGE), "Variations on casing, spaces and tabs");
63+
}, Docopt.ParseSection("usage:", usage), "Variations on casing, spaces and tabs");
6464
}
6565
}
6666
}

0 commit comments

Comments
 (0)