CustomFeaturesTest.java 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class CustomFeaturesTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class CustomFeaturesTest
  12. {
  13. private Console console = new Console();
  14. private CustomFeatures custom = new CustomFeatures(console);
  15. @Test
  16. public void addFiveTest()
  17. {
  18. console.changeCurrentValue(5);
  19. double testAddFive = custom.addFive();
  20. assertEquals(10, testAddFive, 0);
  21. }
  22. @Test
  23. public void helpTest()
  24. {
  25. String testHelp = custom.helpMe();
  26. assertEquals(("Welcome to the help file! \n" + " \n" +
  27. "All of the available commands are listed below \n" +
  28. "with a short description for each command. \n" + " \n" +
  29. "Basic Commands: \n"+
  30. "getValue -> shows you the current stored value in the calculator \n" +
  31. "clear -> resets the current value to 0 \n" +
  32. "changeValue -> sets the current value to a user defined number \n" +
  33. "add -> adds current value to a user defined number \n" +
  34. "subtract -> subtracts a user defined number from the current value \n" +
  35. "multiply -> multiplies the current value by a user defined number \n" +
  36. "divide -> divides current value by a user defined number \n"+
  37. "square -> squares the current value (current value to the 2nd power) \n" +
  38. "SQRT -> calculates the square root of the current value \n" +
  39. "inverse-> calculates 1/(current value) \n" +
  40. "invert -> switches value of current value to negative or vice versa \n" +
  41. "variableEx -> calculates the current value to the user defined power \n" +" \n" +
  42. "Scientific Commands: \n" +
  43. "switchDisplayMode -> changes display mode to binary, octal, decimal, hexadecimal \n" +
  44. "M+ -> Add the currently displayed value to the value in memory \n" +
  45. "MC -> resets memory value to 0 \n" +
  46. "MRC -> recalls the stored memory value \n" +
  47. "sine -> Calculate the sine of the current value \n" +
  48. "cosine -> Calculate the cosine of the current value \n" +
  49. "tangent -> Calculate the tangent of the current value \n" +
  50. "inverseSine -> 1/(sine of current value) \n" +
  51. "inverseCosine -> 1/(cosine of current value) \n" +
  52. "inverseTangent -> 1/(tangent of current value) \n" +
  53. "switchUnitsMode -> sets trig units to Degrees or Radians \n" + " \n" +
  54. "Bonus Features: \n" +
  55. "factorial -> calculates the factorial of the current value \n" +
  56. "log -> calculates the log of the current value \n" +
  57. "inverseLog -> calculates 10^(current value) \n" +
  58. "LN -> calculates the natural logarithm of the current value \n" +
  59. "inverseLN -> calculates e^(current value) \n" + " \n" +
  60. "Custom Features: \n" +
  61. "addFive -> sets current value to result of five plus the current value \n" +
  62. "help -> displays this help file \n" +
  63. "exit -> closes the calculator \n"), testHelp);
  64. }
  65. }