1
0

tests.inc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. Legal:
  3. Version: MPL 1.1
  4. The contents of this file are subject to the Mozilla Public License Version
  5. 1.1 the "License"; you may not use this file except in compliance with
  6. the License. You may obtain a copy of the License at
  7. http://www.mozilla.org/MPL/
  8. Software distributed under the License is distributed on an "AS IS" basis,
  9. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  10. for the specific language governing rights and limitations under the
  11. License.
  12. The Original Code is the YSI framework.
  13. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  14. Portions created by the Initial Developer are Copyright C 2011
  15. the Initial Developer. All Rights Reserved.
  16. Contributors:
  17. Y_Less
  18. koolk
  19. JoeBullet/Google63
  20. g_aSlice/Slice
  21. Misiur
  22. samphunter
  23. tianmeta
  24. maddinat0r
  25. spacemud
  26. Crayder
  27. Dayvison
  28. Ahmad45123
  29. Zeex
  30. irinel1996
  31. Yiin-
  32. Chaprnks
  33. Konstantinos
  34. Masterchen09
  35. Southclaws
  36. PatchwerkQWER
  37. m0k1
  38. paulommu
  39. udan111
  40. Thanks:
  41. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  42. ZeeX - Very productive conversations.
  43. koolk - IsPlayerinAreaEx code.
  44. TheAlpha - Danish translation.
  45. breadfish - German translation.
  46. Fireburn - Dutch translation.
  47. yom - French translation.
  48. 50p - Polish translation.
  49. Zamaroht - Spanish translation.
  50. Los - Portuguese translation.
  51. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  52. me to strive to better.
  53. Pixels^ - Running XScripters where the idea was born.
  54. Matite - Pestering me to release it and using it.
  55. Very special thanks to:
  56. Thiadmer - PAWN, whose limits continue to amaze me!
  57. Kye/Kalcor - SA:MP.
  58. SA:MP Team past, present and future - SA:MP.
  59. Optional plugins:
  60. Gamer_Z - GPS.
  61. Incognito - Streamer.
  62. Me - sscanf2, fixes2, Whirlpool.
  63. */
  64. Test:Player_Existing()
  65. {
  66. new
  67. ret[E_USER_PRELOAD];
  68. Player_Preload("TestPlayer", ret);
  69. ASSERT(0 == ret[E_USER_PRELOAD_YID]);
  70. ASSERT(Langs_GetLanguage("EN") == ret[E_USER_PRELOAD_LANG]);
  71. ASSERT(0x12345678 == ret[E_USER_PRELOAD_BITS]);
  72. ASSERT(0xAABBCCDD >= ret[E_USER_PRELOAD_DATE]);
  73. P:I("Note that if these tests fail, you will need to");
  74. P:I(" first connect to the server as \"TestPlayer\".");
  75. }
  76. new
  77. gBot = INVALID_PLAYER_ID;
  78. Test:Player_ChangeLanguage()
  79. {
  80. // Connect the bot here so that it is done way before the PTest is run.
  81. ConnectNPC("TestPlayer", "npcidle");
  82. }
  83. public OnPlayerConnect(playerid)
  84. {
  85. new
  86. name[MAX_PLAYER_NAME];
  87. GetPlayerName(playerid, name, sizeof (name));
  88. if (!strcmp(name, "TestPlayer")) gBot = playerid;
  89. #if defined Testing_OnPlayerConnect
  90. return Testing_OnPlayerConnect(playerid);
  91. #else
  92. return 1;
  93. #endif
  94. }
  95. #if defined _ALS_OnPlayerConnect
  96. #undef OnPlayerConnect
  97. #else
  98. #define _ALS_OnPlayerConnect
  99. #endif
  100. #define OnPlayerConnect Testing_OnPlayerConnect
  101. #if defined Testing_OnPlayerConnect
  102. forward Testing_OnPlayerConnect(playerid);
  103. #endif
  104. PTestInit:Player_ChangeLanguage(playerid)
  105. {
  106. // So that their language can be changed.
  107. Player_ForceLogin(gBot);
  108. }
  109. PTest:Player_ChangeLanguage(playerid)
  110. {
  111. new
  112. ret[E_USER_PRELOAD];
  113. // Check their language is English, then change it to Dutch.
  114. Player_Preload("TestPlayer", ret);
  115. ASSERT(Langs_GetLanguage("EN") == ret[E_USER_PRELOAD_LANG]);
  116. Player_ChangeLanguage(gBot, "NL");
  117. Player_Preload("TestPlayer", ret);
  118. ASSERT(Langs_GetLanguage("NL") == ret[E_USER_PRELOAD_LANG]);
  119. }
  120. PTestClose:Player_ChangeLanguage(playerid)
  121. {
  122. // Reset the player.
  123. Player_ChangeLanguage(gBot, "EN");
  124. //Kick(gBot);
  125. }
  126. PTestInit:Player_ChangePassword(playerid)
  127. {
  128. // So that their password can be changed.
  129. Player_ForceLogin(gBot);
  130. }
  131. PTest:Player_ChangePassword(playerid)
  132. {
  133. new
  134. ret[E_USER_PRELOAD];
  135. // Change their password.
  136. Player_Preload("TestPlayer", ret);
  137. ASSERT(!strcmp(ret[E_USER_PRELOAD_PASS], "24954A7C4E607137A70D701986CC3C3140C143E5B5886362A8ACB647B81592CF1F092C65178F6E3FFFC6691B044D2290215058E09BBE029D23D1D67F41640090"));
  138. Player_ChangePassword(gBot, "thisisabadpass");
  139. Player_Preload("TestPlayer", ret);
  140. ASSERT(!strcmp(ret[E_USER_PRELOAD_PASS], "B506FEEEDFB83EF44A5DC2E00BF1535E58E3B37A044730F2A6718497A224B5455A441F39F9EB91967B38607416A9B85E5DE3CBE3A48E7A77AB5808674EF33822"));
  141. }
  142. PTestClose:Player_ChangePassword(playerid)
  143. {
  144. // Reset the player.
  145. Player_ChangePassword(gBot, "thisisanOKpass");
  146. //Kick(gBot);
  147. }
  148. PTestInit:Player_Preload(playerid)
  149. {
  150. Player_ForceLogin(gBot);
  151. }
  152. PTest:Player_Preload(playerid)
  153. {
  154. new
  155. //name[MAX_PLAYER_NAME],
  156. ret[E_USER_PRELOAD];
  157. //GetPlayerName(playerid, name, sizeof (name));
  158. Player_Preload("TestPlayer", ret);
  159. ASSERT(Player_GetYID(gBot) == ret[E_USER_PRELOAD_YID]);
  160. ASSERT(Langs_GetPlayerLanguage(gBot) == ret[E_USER_PRELOAD_LANG]);
  161. ASSERT(0x12345678 == ret[E_USER_PRELOAD_BITS]);
  162. ASSERT(gettime() >= ret[E_USER_PRELOAD_DATE]);
  163. }
  164. PTestInit:Player_GetID(playerid)
  165. {
  166. // So that their password can be changed.
  167. Player_ForceLogin(gBot);
  168. }
  169. PTest:Player_GetID(playerid)
  170. {
  171. ASSERT(Player_GetYID(gBot) == 0);
  172. ASSERT(Player_GetYID(playerid) < 0);
  173. }