Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using NUnit.Framework;
- namespace Manipulation
- {
- public class TriangleTask
- {
- public static double GetABAngle(double a, double b, double c)
- {
- if (double.IsNaN(a) || double.IsNaN(b) || double.IsNaN(c)
- || a < 0 || b < 0 || c < 0
- || (c == 0 && (a == 0 || b == 0)))
- {
- return double.NaN;
- }
- return Math.Acos((b * b + a * a - c * c) / (2 * a * b));
- }
- }
- [TestFixture]
- public class TriangleTask_Tests
- {
- [TestCase(3, 4, 5, Math.PI / 2)]
- [TestCase(1, 1, 1, Math.PI / 3)]
- [TestCase(1, 1, 3, double.NaN)]
- [TestCase(-1, 1, 1, double.NaN)]
- [TestCase(1, 0, 1, double.NaN)]
- [TestCase(1, 1, 0, 0)]
- [TestCase(1, 0, 0, double.NaN)]
- [TestCase(0, 1, 0, double.NaN)]
- [TestCase(0, 0, 1, double.NaN)]
- [TestCase(0, 0, 0, double.NaN)]
- public void TestGetABAngle(double a, double b, double c, double expectedAngle)
- {
- Assert.AreEqual(TriangleTask.GetABAngle(a, b, c), expectedAngle, 1e-5);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement