Esempio n. 1
0
        public void StringInterop()
        {
            var v = new lvec2(-2L, 6L);

            var s0 = v.ToString();
            var s1 = v.ToString("#");

            var v0 = lvec2.Parse(s0);
            var v1 = lvec2.Parse(s1, "#");

            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            var b0 = lvec2.TryParse(s0, out v0);
            var b1 = lvec2.TryParse(s1, "#", out v1);

            Assert.That(b0);
            Assert.That(b1);
            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            b0 = lvec2.TryParse(null, out v0);
            Assert.False(b0);
            b0 = lvec2.TryParse("", out v0);
            Assert.False(b0);
            b0 = lvec2.TryParse(s0 + ", 0", out v0);
            Assert.False(b0);

            Assert.Throws <NullReferenceException>(() => { lvec2.Parse(null); });
            Assert.Throws <FormatException>(() => { lvec2.Parse(""); });
            Assert.Throws <FormatException>(() => { lvec2.Parse(s0 + ", 0"); });

            var s2 = v.ToString(";", CultureInfo.InvariantCulture);

            Assert.That(s2.Length > 0);

            var s3 = v.ToString("; ", "G");
            var s4 = v.ToString("; ", "G", CultureInfo.InvariantCulture);
            var v3 = lvec2.Parse(s3, "; ", NumberStyles.Number);
            var v4 = lvec2.Parse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture);

            Assert.AreEqual(v, v3);
            Assert.AreEqual(v, v4);

            var b4 = lvec2.TryParse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture, out v4);

            Assert.That(b4);
            Assert.AreEqual(v, v4);
        }
Esempio n. 2
0
 /// <summary>
 /// Returns a string representation of this vector using a provided seperator and a format and format provider for each component.
 /// </summary>
 public static string ToString(lvec2 v, string sep, string format, IFormatProvider provider) => v.ToString(sep, format, provider);
Esempio n. 3
0
 /// <summary>
 /// Returns a string representation of this vector using a provided seperator and a format for each component.
 /// </summary>
 public static string ToString(lvec2 v, string sep, string format) => v.ToString(sep, format);
Esempio n. 4
0
 /// <summary>
 /// Returns a string representation of this vector using a provided seperator.
 /// </summary>
 public static string ToString(lvec2 v, string sep) => v.ToString(sep);
Esempio n. 5
0
 /// <summary>
 /// Returns a string representation of this vector using ', ' as a seperator.
 /// </summary>
 public static string ToString(lvec2 v) => v.ToString();