public void StringInterop() { var v = new float2(-9f, -6.5f); var s0 = v.ToString(); var s1 = v.ToString("#"); var v0 = float2.Parse(s0); var v1 = float2.Parse(s1, "#"); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); var b0 = float2.TryParse(s0, out v0); var b1 = float2.TryParse(s1, "#", out v1); Assert.That(b0); Assert.That(b1); Assert.AreEqual(v, v0); Assert.AreEqual(v, v1); b0 = float2.TryParse(null, out v0); Assert.False(b0); b0 = float2.TryParse("", out v0); Assert.False(b0); b0 = float2.TryParse(s0 + ", 0", out v0); Assert.False(b0); Assert.Throws <NullReferenceException>(() => { float2.Parse(null); }); Assert.Throws <FormatException>(() => { float2.Parse(""); }); Assert.Throws <FormatException>(() => { float2.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 = float2.Parse(s3, "; ", NumberStyles.Number); var v4 = float2.Parse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture); Assert.AreEqual(v, v3); Assert.AreEqual(v, v4); var b4 = float2.TryParse(s4, "; ", NumberStyles.Number, CultureInfo.InvariantCulture, out v4); Assert.That(b4); Assert.AreEqual(v, v4); }
public override string ToString() { string a = Min.ToString(); string b = Max.ToString(); return(a + ", " + b); }
public void ToString_CultureDE() { string s = "(1,5; 1,5)"; float2 f = float2.One * 1.5f; Assert.Equal(s, f.ToString(new CultureInfo("de-DE"))); }
public override string ToString() { string a = Origin.ToString(); string b = Direction.ToString(); return("p" + a + " + t * " + b); }
public void ToString_InvariantCulture() { string s = "(1.5, 1.5)"; float2 f = float2.One * 1.5f; Assert.Equal(s, f.ToString(CultureInfo.InvariantCulture)); }
public void Float2_WriteToString(float v0, float v1) { string s = NormalFormat.F(v0, v1); float2 n = new float2(v0, v1); string sn = n.ToString(); Assert.That(sn, Is.EqualTo(s)); }
private Gamepad GetConnectingGamepad() { foreach (Gamepad pad in Gamepad.all) { if (!IsConnected(pad.deviceId)) { if (pad.startButton.wasPressedThisFrame || pad.selectButton.wasPressedThisFrame || pad.aButton.wasPressedThisFrame || pad.bButton.wasPressedThisFrame || pad.yButton.wasPressedThisFrame || pad.xButton.wasPressedThisFrame || pad.leftTrigger.wasPressedThisFrame || pad.rightTrigger.wasPressedThisFrame || pad.leftShoulder.wasPressedThisFrame || pad.rightShoulder.wasPressedThisFrame || pad.leftStickButton.wasPressedThisFrame || pad.rightStickButton.wasPressedThisFrame || pad.buttonEast.wasPressedThisFrame || pad.buttonNorth.wasPressedThisFrame || pad.buttonSouth.wasPressedThisFrame || pad.buttonWest.wasPressedThisFrame || pad.crossButton.wasPressedThisFrame || pad.circleButton.wasPressedThisFrame || pad.triangleButton.wasPressedThisFrame || pad.squareButton.wasPressedThisFrame) { Debug.Log("Buttons were pressed."); return(pad); } float2 leftStick = pad.leftStick.ReadValue(); float2 rightStick = pad.rightStick.ReadValue(); if (math.abs(leftStick.x) > 0.49f || math.abs(leftStick.y) > 0.49f || math.abs(rightStick.x) > 0.49f || math.abs(rightStick.y) > 0.49f) { Debug.Log("Sticks were pressed:" + leftStick.ToString() + ":" + rightStick.ToString()); return(pad); } } } return(null); }
public void ConvertFromFloat2(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 = f2.ToString(); 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.f2 = f2; root.Attach("f2", node, "i"); root.Attach("f2", node, "f"); root.Attach("f2", node, "d"); root.Attach("f2", node, "isTrue"); root.Attach("f2", node, "text"); root.Attach("f2", node, "d2"); root.Attach("f2", node, "d3"); root.Attach("f2", node, "d4"); root.Attach("f2", node, "d4x4"); root.Attach("f2", node, "f2"); root.Attach("f2", node, "f3"); root.Attach("f2", node, "f4"); root.Attach("f2", 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 + "."); }
public override string ToString() { return(string.Format("min:{0} max:{1}", min.ToString(), max.ToString())); }
public void Parse_ToString_CultureDE() { float2 f = float2.One * 1.5f; Assert.Equal(f, float2.Parse(f.ToString(new CultureInfo("de-DE")), new CultureInfo("de-DE"))); }
public void Parse_ToString_InvariantCulture() { float2 f = float2.One * 1.5f; Assert.Equal(f, float2.Parse(f.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture)); }
public void Parse_ToString_NoCulture() { float2 f = float2.One * 1.5f; Assert.Equal(f, float2.Parse(f.ToString())); }
/// <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(float2 v, string sep, string format, IFormatProvider provider) => v.ToString(sep, format, provider);
/// <summary> /// Returns a string representation of this vector using a provided seperator and a format for each component. /// </summary> public static string ToString(float2 v, string sep, string format) => v.ToString(sep, format);
/// <summary> /// Returns a string representation of this vector using a provided seperator. /// </summary> public static string ToString(float2 v, string sep) => v.ToString(sep);
/// <summary> /// Returns a string representation of this vector using ', ' as a seperator. /// </summary> public static string ToString(float2 v) => v.ToString();