tests.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. static
  2. YSI_g_sVariable;
  3. forward y_va_PublicTestFunction(vara, varb);
  4. public y_va_PublicTestFunction(vara, varb)
  5. {
  6. if (vara)
  7. {
  8. YSI_g_sVariable = varb;
  9. }
  10. else
  11. {
  12. ++YSI_g_sVariable;
  13. }
  14. }
  15. static stock y_va_CallRemoteFunction(va_args<>)
  16. {
  17. va_CallRemoteFunction("y_va_PublicTestFunction", "ii", va_start<0>);
  18. }
  19. Test:y_va_CallRemoteFunction()
  20. {
  21. YSI_g_sVariable = 5;
  22. y_va_CallRemoteFunction(0, 11);
  23. ASSERT(YSI_g_sVariable == 6);
  24. y_va_CallRemoteFunction(1, 11);
  25. ASSERT(YSI_g_sVariable == 11);
  26. }
  27. static stock y_va_CallLocalFunction(va_args<>)
  28. {
  29. va_CallLocalFunction("y_va_PublicTestFunction", "ii", va_start<0>);
  30. }
  31. Test:y_va_CallLocalFunction()
  32. {
  33. YSI_g_sVariable = 8;
  34. y_va_CallLocalFunction(0, 45);
  35. ASSERT(YSI_g_sVariable == 9);
  36. y_va_CallLocalFunction(1, 45);
  37. ASSERT(YSI_g_sVariable == 45);
  38. }
  39. static stock y_va_format(dest[], size, fmat[], va_args<>)
  40. {
  41. va_format(dest, size, fmat, va_start<3>);
  42. }
  43. Test:y_va_format()
  44. {
  45. new
  46. str[64];
  47. y_va_format(str, sizeof (str), "Hello %d %04x %s", 99, 0x1F, "woop");
  48. ASSERT(!strcmp(str, "Hello 99 001F woop"));
  49. }
  50. static stock y_va_return(dest[], size, fmat[], va_args<>)
  51. {
  52. strcpy(dest, va_return(fmat, va_start<3>), size);
  53. }
  54. Test:y_va_return()
  55. {
  56. new
  57. str[YSI_MAX_STRING * 8];
  58. y_va_return(str, sizeof (str), "Hi %.3f %8.8s %8.8s", 5.5, "this is a very long string", "short");
  59. ASSERT(!strcmp(str, "Hi 5.500 this is short "));
  60. }