test.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #include "stdafx.h"
  23. #include "tsk.h"
  24. #include "tinysms.h"
  25. char* tohex(uint8_t* ptr, size_t size)
  26. {
  27. char* ret = tsk_null;
  28. size_t i;
  29. for(i=0; i<size; i++) {
  30. tsk_strcat_2(&ret, "%.2X", *ptr++);
  31. }
  32. return ret;
  33. }
  34. void printhex(const char* what, uint8_t* ptr, size_t size)
  35. {
  36. size_t i;
  37. printf("%s", what);
  38. for(i=0; i<size; i++) {
  39. printf("%.2X", *ptr++);
  40. }
  41. printf("\n");
  42. }
  43. tsk_bool_t bin_equals(const uint8_t* b1, const uint8_t* b2, size_t size)
  44. {
  45. size_t i;
  46. // we assume that sizeof(b1)==sizeof(b2)
  47. if(!b1 || !b2 || !size) {
  48. return tsk_false;
  49. }
  50. for(i=0; i<size; i++) {
  51. if(b1[i] != b2[i]) {
  52. return tsk_false;
  53. }
  54. }
  55. return tsk_true;
  56. }
  57. #include "test_packing.h"
  58. #include "test_tpdu.h"
  59. #include "test_rpdu.h"
  60. #define RUN_TEST_LOOP 1
  61. #define RUN_TEST_ALL 0
  62. #define RUN_TEST_PACKING 0
  63. #define RUN_TEST_TPDU 0
  64. #define RUN_TEST_RPDU 1
  65. #ifdef _WIN32_WCE
  66. int _tmain(int argc, _TCHAR* argv[])
  67. #else
  68. int main()
  69. #endif
  70. {
  71. #if RUN_TEST_LOOP
  72. for(;;)
  73. #endif
  74. {
  75. /* Print copyright information */
  76. printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
  77. #if RUN_TEST_ALL || RUN_TEST_PACKING
  78. test_packing();
  79. #endif
  80. #if RUN_TEST_ALL || RUN_TEST_TPDU
  81. test_tpdu();
  82. #endif
  83. #if RUN_TEST_ALL || RUN_TEST_RPDU
  84. test_rpdu();
  85. #endif
  86. }
  87. }