CurrencyConverterTest.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import org.junit.Assert;
  2. import org.junit.Test;
  3. public class CurrencyConverterTest {
  4. @Test
  5. public void firstCurrTest(){
  6. CurrencyConverter conv = new CurrencyConverter();
  7. double actual = conv.firstCurr("jy");
  8. double expected = 115.84;
  9. Assert.assertEquals(expected, actual,.0001);
  10. }
  11. @Test
  12. public void getCurrency2test(){
  13. CurrencyConverter conv = new CurrencyConverter();
  14. double actual = conv.secCurr("sd");
  15. double expected = 1.43;
  16. Assert.assertEquals(expected, actual,.0001);
  17. }
  18. @Test
  19. public void convertTest1(){
  20. CurrencyConverter conv = new CurrencyConverter();
  21. double actual = conv.convert("us","jy",1);
  22. double expected = 115.84;
  23. Assert.assertEquals(expected, actual,.0001);
  24. }
  25. @Test
  26. public void convertDollarToEuro(){
  27. CurrencyConverter conv = new CurrencyConverter();
  28. double actual = conv.convert("us","eu",1);
  29. double expected = .94;
  30. Assert.assertEquals(expected, actual,.0001);
  31. }
  32. @Test
  33. public void convertEuroToDollar(){
  34. CurrencyConverter conv = new CurrencyConverter();
  35. double actual = conv.convert("eu","us",1);
  36. double expected = 1.063829;
  37. Assert.assertEquals(expected, actual,.0001);
  38. }
  39. @Test
  40. public void convertEuroToBritishPound(){
  41. CurrencyConverter conv = new CurrencyConverter();
  42. double actual = conv.convert("eu","bp",1);
  43. double expected = .8723404;
  44. Assert.assertEquals(expected, actual,.0001);
  45. }
  46. @Test
  47. public void convertBritishPoundToIndianRupee(){
  48. CurrencyConverter conv = new CurrencyConverter();
  49. double actual = conv.convert("bp","ir",1);
  50. double expected = 83.31707;
  51. Assert.assertEquals(expected, actual,.0001);
  52. }
  53. @Test
  54. public void convertRupeetoCanadian(){
  55. CurrencyConverter conv = new CurrencyConverter();
  56. double actual = conv.convert("ir","cd",1);
  57. double expected = .01932084;
  58. Assert.assertEquals(expected, actual,.0001);
  59. }
  60. @Test
  61. public void convertCanadianToSingapore(){
  62. CurrencyConverter conv = new CurrencyConverter();
  63. double actual = conv.convert("cd","sd",1);
  64. double expected = 1.0833333333;
  65. Assert.assertEquals(expected, actual,.0001);
  66. }
  67. @Test
  68. public void convertSingaporeToSwiss(){
  69. CurrencyConverter conv = new CurrencyConverter();
  70. double actual = conv.convert("sd","sf",1);
  71. double expected = .70629370;
  72. Assert.assertEquals(expected, actual,.0001);
  73. }
  74. @Test
  75. public void convertSwissToMalaysian(){
  76. CurrencyConverter conv = new CurrencyConverter();
  77. double actual = conv.convert("sf","mr",1);
  78. double expected = 4.4257425;
  79. Assert.assertEquals(expected, actual,.0001);
  80. }
  81. @Test
  82. public void convertMalaysianToYen(){
  83. CurrencyConverter conv = new CurrencyConverter();
  84. double actual = conv.convert("mr","jy",1);
  85. double expected = 25.9149888;
  86. Assert.assertEquals(expected, actual,.0001);
  87. }
  88. @Test
  89. public void convertYenToYuan(){
  90. CurrencyConverter conv = new CurrencyConverter();
  91. double actual = conv.convert("jy","cy",1);
  92. double expected = .05973756;
  93. Assert.assertEquals(expected, actual,.0001);
  94. }
  95. }