return;
}
}
- if (index == 2) {
- if (zero) {
- offset = lens [0] + lens [1] + 2;
- length = format.Length - offset;
- return;
- }
- if (positive) {
- offset = 0;
- length = lens [0];
- return;
- }
- if (lens [1] > 0) {
- positive = true;
- offset = lens [0] + 1;
- length = lens [1];
+ if (zero) {
+ if (index == 2) {
+ if (format.Length - lastPos == 0) {
+ offset = 0;
+ length = lens [0];
+ } else {
+ offset = lens [0] + lens [1] + 2;
+ length = format.Length - offset;
+ }
return;
}
- else {
+
+ if (lens [2] == 0) {
offset = 0;
length = lens [0];
- return;
- }
- }
- if (index == 3) {
- if (zero) {
+ } else {
offset = lens [0] + lens [1] + 2;
length = lens [2];
- return;
- }
- if (positive) {
- offset = 0;
- length = lens [0];
- return;
- }
- if (lens [1] > 0) {
- positive = true;
- offset = lens [0] + 1;
- length = lens [1];
- return;
- }
- else {
- offset = 0;
- length = lens [0];
- return;
}
- }
- throw new ArgumentException ();
+ return;
+
+ }
+ if (positive) {
+ offset = 0;
+ length = lens [0];
+ return;
+ }
+ if (lens [1] > 0) {
+ positive = true;
+ offset = lens [0] + 1;
+ length = lens [1];
+ return;
+ }
+ offset = 0;
+ length = lens [0];
}
public static CustomInfo Parse (string format, int offset, int length, NumberFormatInfo nfi)
int hundred = 100;
int neghund = -100;
- Assert.IsTrue ( hundred.ToString ("#;#") == "100", "#TS1");
- Assert.IsTrue ( hundred.ToString ("-#;#") == "-100", "#TS2");
- Assert.IsTrue ( neghund.ToString ("#;#") == "100", "#TS3");
- Assert.IsTrue ( neghund.ToString ("#;-#") == "-100", "#TS3");
+ Assert.AreEqual ("100", hundred.ToString ("#;#"), "#TS1");
+ Assert.AreEqual ("-100", hundred.ToString ("-#;#"), "#TS2");
+ Assert.AreEqual ("100", neghund.ToString ("#;#"), "#TS3");
+ Assert.AreEqual ("-100", neghund.ToString ("#;-#"), "#TS4");
+ Assert.AreEqual ("3", 0.ToString ("3;;"), "#TS5");
+ Assert.AreEqual ("3", 0.ToString ("3;2;"), "#TS6");
+ Assert.AreEqual ("3", 0.ToString ("3;"), "#TS7");
+ Assert.AreEqual ("3", 0.ToString ("3;;;;;;;"), "#TS8");
}
[Test]