1
0

NumberHelperTest.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. namespace fphammerle\helpers\tests;
  3. use \fphammerle\helpers\NumberHelper;
  4. class NumberHelperTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function setBasenameProvider()
  7. {
  8. return [
  9. [1, 'I'],
  10. [2, 'II'],
  11. [3, 'III'],
  12. [4, 'IV'],
  13. [5, 'V'],
  14. [6, 'VI'],
  15. [7, 'VII'],
  16. [8, 'VIII'],
  17. [9, 'IX'],
  18. [10, 'X'],
  19. [11, 'XI'],
  20. [12, 'XII'],
  21. [13, 'XIII'],
  22. [14, 'XIV'],
  23. [15, 'XV'],
  24. [16, 'XVI'],
  25. [17, 'XVII'],
  26. [18, 'XVIII'],
  27. [19, 'XIX'],
  28. [20, 'XX'],
  29. [21, 'XXI'],
  30. [22, 'XXII'],
  31. [23, 'XXIII'],
  32. [24, 'XXIV'],
  33. [25, 'XXV'],
  34. [26, 'XXVI'],
  35. [27, 'XXVII'],
  36. [28, 'XXVIII'],
  37. [29, 'XXIX'],
  38. [30, 'XXX'],
  39. [31, 'XXXI'],
  40. [32, 'XXXII'],
  41. [33, 'XXXIII'],
  42. [34, 'XXXIV'],
  43. [35, 'XXXV'],
  44. [36, 'XXXVI'],
  45. [37, 'XXXVII'],
  46. [38, 'XXXVIII'],
  47. [39, 'XXXIX'],
  48. [40, 'XL'],
  49. [41, 'XLI'],
  50. [42, 'XLII'],
  51. [43, 'XLIII'],
  52. [44, 'XLIV'],
  53. [45, 'XLV'],
  54. [46, 'XLVI'],
  55. [47, 'XLVII'],
  56. [48, 'XLVIII'],
  57. [49, 'XLIX'],
  58. [50, 'L'],
  59. [51, 'LI'],
  60. [52, 'LII'],
  61. [53, 'LIII'],
  62. [54, 'LIV'],
  63. [55, 'LV'],
  64. [56, 'LVI'],
  65. [57, 'LVII'],
  66. [58, 'LVIII'],
  67. [59, 'LIX'],
  68. [60, 'LX'],
  69. [61, 'LXI'],
  70. [62, 'LXII'],
  71. [63, 'LXIII'],
  72. [64, 'LXIV'],
  73. [65, 'LXV'],
  74. [66, 'LXVI'],
  75. [67, 'LXVII'],
  76. [68, 'LXVIII'],
  77. [69, 'LXIX'],
  78. [70, 'LXX'],
  79. [71, 'LXXI'],
  80. [72, 'LXXII'],
  81. [73, 'LXXIII'],
  82. [74, 'LXXIV'],
  83. [75, 'LXXV'],
  84. [76, 'LXXVI'],
  85. [77, 'LXXVII'],
  86. [78, 'LXXVIII'],
  87. [79, 'LXXIX'],
  88. [80, 'LXXX'],
  89. [81, 'LXXXI'],
  90. [82, 'LXXXII'],
  91. [83, 'LXXXIII'],
  92. [84, 'LXXXIV'],
  93. [85, 'LXXXV'],
  94. [86, 'LXXXVI'],
  95. [87, 'LXXXVII'],
  96. [88, 'LXXXVIII'],
  97. [89, 'LXXXIX'],
  98. [90, 'XC'],
  99. [91, 'XCI'],
  100. [92, 'XCII'],
  101. [93, 'XCIII'],
  102. [94, 'XCIV'],
  103. [95, 'XCV'],
  104. [96, 'XCVI'],
  105. [97, 'XCVII'],
  106. [98, 'XCVIII'],
  107. [99, 'XCIX'],
  108. [100, 'C'],
  109. [101, 'CI'],
  110. [104, 'CIV'],
  111. [109, 'CIX'],
  112. [149, 'CXLIX'],
  113. [161, 'CLXI'],
  114. [177, 'CLXXVII'],
  115. [189, 'CLXXXIX'],
  116. [199, 'CXCIX'],
  117. [200, 'CC'],
  118. [201, 'CCI'],
  119. [204, 'CCIV'],
  120. [209, 'CCIX'],
  121. [249, 'CCXLIX'],
  122. [261, 'CCLXI'],
  123. [277, 'CCLXXVII'],
  124. [289, 'CCLXXXIX'],
  125. [299, 'CCXCIX'],
  126. [300, 'CCC'],
  127. [400, 'CD'],
  128. [401, 'CDI'],
  129. [404, 'CDIV'],
  130. [409, 'CDIX'],
  131. [449, 'CDXLIX'],
  132. [461, 'CDLXI'],
  133. [477, 'CDLXXVII'],
  134. [489, 'CDLXXXIX'],
  135. [499, 'CDXCIX'],
  136. [500, 'D'],
  137. [600, 'DC'],
  138. [700, 'DCC'],
  139. [800, 'DCCC'],
  140. [900, 'CM'],
  141. [1000, 'M'],
  142. [1100, 'MC'],
  143. [1200, 'MCC'],
  144. [1300, 'MCCC'],
  145. [1400, 'MCD'],
  146. [1500, 'MD'],
  147. [1600, 'MDC'],
  148. [1700, 'MDCC'],
  149. [1800, 'MDCCC'],
  150. [1900, 'MCM'],
  151. [1990, 'MCMXC'],
  152. [1991, 'MCMXCI'],
  153. [1992, 'MCMXCII'],
  154. [1993, 'MCMXCIII'],
  155. [1994, 'MCMXCIV'],
  156. [1995, 'MCMXCV'],
  157. [1996, 'MCMXCVI'],
  158. [1997, 'MCMXCVII'],
  159. [1998, 'MCMXCVIII'],
  160. [1999, 'MCMXCIX'],
  161. [2000, 'MM'],
  162. [2001, 'MMI'],
  163. [2002, 'MMII'],
  164. [2003, 'MMIII'],
  165. [2004, 'MMIV'],
  166. [2005, 'MMV'],
  167. [2006, 'MMVI'],
  168. [2007, 'MMVII'],
  169. [2008, 'MMVIII'],
  170. [2009, 'MMIX'],
  171. [2010, 'MMX'],
  172. [2011, 'MMXI'],
  173. [2012, 'MMXII'],
  174. [2013, 'MMXIII'],
  175. [2014, 'MMXIV'],
  176. [2015, 'MMXV'],
  177. [2016, 'MMXVI'],
  178. [2017, 'MMXVII'],
  179. [2018, 'MMXVIII'],
  180. [2019, 'MMXIX'],
  181. [2020, 'MMXX'],
  182. ];
  183. }
  184. /**
  185. * @dataProvider setBasenameProvider
  186. */
  187. public function testFormatRoman($number, $expected_roman)
  188. {
  189. $this->assertSame($expected_roman, NumberHelper::formatRoman($number));
  190. }
  191. }