예제 #1
0
        public void StringInterop()
        {
            var v = new float4(8f, 6f, 1f, 5f);

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

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

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

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

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

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

            Assert.Throws <NullReferenceException>(() => { float4.Parse(null); });
            Assert.Throws <FormatException>(() => { float4.Parse(""); });
            Assert.Throws <FormatException>(() => { float4.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 = float4.Parse(s3, "; ", NumberStyles.Number);
            var v4 = float4.Parse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture);

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

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

            Assert.That(b4);
            Assert.AreEqual(v, v4);
        }
예제 #2
0
        public void ToString_CultureDE()
        {
            string s = "(1,5; 1,5; 1,5; 1,5)";
            float4 f = float4.One * 1.5f;

            Assert.Equal(s, f.ToString(new CultureInfo("de-DE")));
        }
예제 #3
0
        public void ToString_InvariantCulture()
        {
            string s = "(1.5, 1.5, 1.5, 1.5)";
            float4 f = float4.One * 1.5f;

            Assert.Equal(s, f.ToString(CultureInfo.InvariantCulture));
        }
예제 #4
0
        public void Float4_WriteToString(float v0, float v1, float v2, float v3)
        {
            string s  = NormalFormat.F(v0, v1, v2, v3);
            float4 n  = new float4(v0, v1, v2, v3);
            string sn = n.ToString();

            Assert.That(sn, Is.EqualTo(s));
        }
예제 #5
0
        public void ConvertFromFloat4(int i, float f, double d, bool isTrue, string text, double2 d2, double3 d3, double4 d4, double4x4 d4x4, float2 f2, float3 f3, float4 f4, float4x4 f4x4)
        {
            text = f4.ToString();
            d4x4 = new double4x4(d4, new double4(0, 0, 0, 0), new double4(0, 0, 0, 0), new double4(0, 0, 0, 0));
            f4x4 = new float4x4(f4, new float4(0, 0, 0, 0), new float4(0, 0, 0, 0), new float4(0, 0, 0, 0));

            ConverterClass source   = new ConverterClass();
            ConverterClass expected = new ConverterClass();
            Node           root     = new Node(source);
            Node           node     = new Node(expected);
            Circuit        circuit  = new Circuit();

            circuit.AddNode(root);
            circuit.AddNode(node);
            circuit.AddRoot(root);

            source.f4 = f4;

            root.Attach("f4", node, "i");
            root.Attach("f4", node, "f");
            root.Attach("f4", node, "d");
            root.Attach("f4", node, "isTrue");
            root.Attach("f4", node, "text");
            root.Attach("f4", node, "d2");
            root.Attach("f4", node, "d3");
            root.Attach("f4", node, "d4");
            root.Attach("f4", node, "d4x4");
            root.Attach("f4", node, "f2");
            root.Attach("f4", node, "f3");
            root.Attach("f4", node, "f4");
            root.Attach("f4", node, "f4x4");

            circuit.Execute();

            Assert.True(expected.i == i, "Error when parsing to int: Should be " + i + " but is " + expected.i + ".");
            Assert.True(expected.f == f, "Error when parsing to float: Should be " + f + " but is " + expected.f + ".");
            Assert.True(expected.d == d, "Error when parsing to double: Should be " + d + " but is " + expected.d + ".");
            Assert.True(expected.isTrue == isTrue, "Error when parsing to bool: Should be " + isTrue + " but is " + expected.isTrue + ".");
            Assert.True(expected.text == text, "Error when parsing to string: Should be " + text + " but is " + expected.text + ".");
            Assert.True(expected.d2 == d2, "Error when parsing to double2: Should be " + d2 + " but is " + expected.d2 + ".");
            Assert.True(expected.d3 == d3, "Error when parsing to double3: Should be " + d3 + " but is " + expected.d3 + ".");
            Assert.True(expected.d4 == d4, "Error when parsing to double4: Should be " + d4 + " but is " + expected.d4 + ".");
            Assert.True(expected.d4x4 == d4x4, "Error when parsing to double4x4: Should be " + d4x4 + " but is " + expected.d4x4 + ".");
            Assert.True(expected.f2 == f2, "Error when parsing to float2: Should be " + f2 + " but is " + expected.f2 + ".");
            Assert.True(expected.f3 == f3, "Error when parsing to float3: Should be " + f3 + " but is " + expected.f3 + ".");
            Assert.True(expected.f4 == f4, "Error when parsing to float4: Should be " + f4 + " but is " + expected.f4 + ".");
            Assert.True(expected.f4x4 == f4x4, "Error when parsing to float4x4: Should be " + f4x4 + " but is " + expected.f4x4 + ".");
        }
예제 #6
0
        public void Parse_ToString_CultureDE()
        {
            float4 f = float4.One * 1.5f;

            Assert.Equal(f, float4.Parse(f.ToString(new CultureInfo("de-DE")), new CultureInfo("de-DE")));
        }
예제 #7
0
        public void Parse_ToString_InvariantCulture()
        {
            float4 f = float4.One * 1.5f;

            Assert.Equal(f, float4.Parse(f.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture));
        }
예제 #8
0
        public void Parse_ToString_NoCulture()
        {
            float4 f = float4.One * 1.5f;

            Assert.Equal(f, float4.Parse(f.ToString()));
        }
예제 #9
0
 public static void              SetPaletteColor(int _paletteIndex, float4 _HDRColor)
 {
     SetRegistryValue("Entry" + _paletteIndex, _HDRColor.ToString());
 }
예제 #10
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(float4 v, string sep, string format, IFormatProvider provider) => v.ToString(sep, format, provider);
예제 #11
0
 /// <summary>
 /// Returns a string representation of this vector using a provided seperator and a format for each component.
 /// </summary>
 public static string ToString(float4 v, string sep, string format) => v.ToString(sep, format);
예제 #12
0
 /// <summary>
 /// Returns a string representation of this vector using a provided seperator.
 /// </summary>
 public static string ToString(float4 v, string sep) => v.ToString(sep);
예제 #13
0
 /// <summary>
 /// Returns a string representation of this vector using ', ' as a seperator.
 /// </summary>
 public static string ToString(float4 v) => v.ToString();