SHARE
TWEET

Untitled

a guest Nov 19th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using NUnit.Framework;
  3.  
  4. namespace Manipulation
  5. {
  6.     public class TriangleTask
  7.     {
  8.         public static double GetABAngle(double a, double b, double c)
  9.         {
  10.             if (double.IsNaN(a) || double.IsNaN(b) || double.IsNaN(c)
  11.                 || a < 0 || b < 0 || c < 0
  12.                 || (c == 0 && (a == 0 || b == 0)))
  13.             {
  14.                 return double.NaN;
  15.             }
  16.             return Math.Acos((b * b + a * a - c * c) / (2 * a * b));
  17.         }
  18.     }
  19.  
  20.     [TestFixture]
  21.     public class TriangleTask_Tests
  22.     {
  23.         [TestCase(3, 4, 5, Math.PI / 2)]
  24.         [TestCase(1, 1, 1, Math.PI / 3)]
  25.         [TestCase(1, 1, 3, double.NaN)]
  26.         [TestCase(-1, 1, 1, double.NaN)]
  27.         [TestCase(1, 0, 1, double.NaN)]
  28.         [TestCase(1, 1, 0, 0)]
  29.         [TestCase(1, 0, 0, double.NaN)]
  30.         [TestCase(0, 1, 0, double.NaN)]
  31.         [TestCase(0, 0, 1, double.NaN)]
  32.         [TestCase(0, 0, 0, double.NaN)]
  33.         public void TestGetABAngle(double a, double b, double c, double expectedAngle)
  34.         {
  35.             Assert.AreEqual(TriangleTask.GetABAngle(a, b, c), expectedAngle, 1e-5);
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top