ScientificFeaturesTest.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import static org.junit.Assert.*;
  2. import org.junit.Test;
  3. /**
  4. * The test class ScientificFeaturesTest.
  5. */
  6. public class ScientificFeaturesTest
  7. {
  8. Console console = new Console();
  9. ScientificFeatures test = new ScientificFeatures(console);
  10. @Test
  11. public void switchDisplayModeTest(){
  12. //Given
  13. String test1 = "binary";
  14. //When
  15. int actual = 2;
  16. int expected = test.switchDisplayMode(test1);
  17. //Then
  18. assertEquals(expected,actual);
  19. }
  20. @Test
  21. public void switchUnitsModeTest(){
  22. //Given;
  23. String test1 = "radians";
  24. //When
  25. String actual = "radians";
  26. String expected = test.switchUnitsMode(test1);
  27. //Then
  28. assertEquals(expected,actual);
  29. }
  30. @Test
  31. public void sineTest(){
  32. //Given
  33. double test1 = 90;
  34. //When
  35. double actual = 1.0;
  36. double expected = test.sine(test1);
  37. //Then
  38. assertEquals(expected,actual,.11);
  39. }
  40. @Test
  41. public void cosineTest(){
  42. //Given
  43. double test1 = 180.0;
  44. //When
  45. double actual = -1.0;
  46. double expected = test.cosine(test1);
  47. //Then
  48. assertEquals(expected,actual,0);
  49. }
  50. @Test
  51. public void tangentTest(){
  52. //Given
  53. double test1 = 0.0;
  54. //When
  55. double actual = 0.0;
  56. double expected = test.tangent(test1);
  57. //Then
  58. assertEquals(expected,actual,.0001);
  59. }
  60. @Test
  61. public void invSineTest(){
  62. //Given
  63. double test1 = 0.0;
  64. //When
  65. double actual = 0.0;
  66. double expected = test.invSine(test1);
  67. //Then
  68. assertEquals(expected,actual,0);
  69. }
  70. @Test
  71. public void invCosineTest(){
  72. //Given
  73. double test1 = 0.0;
  74. //When
  75. double actual = 1.57;
  76. double expected = test.invCosine(test1);
  77. //Then
  78. assertEquals(expected,actual,.01);
  79. }
  80. @Test
  81. public void invTangentTest(){
  82. //Given
  83. double test1 = 0.0;
  84. //When
  85. double actual = 0.0;
  86. double expected = test.invTangent(test1);
  87. //Then
  88. assertEquals(expected,actual,0);
  89. }
  90. }