test_suite_base64.function 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. BEGIN_HEADER
  2. #include <polarssl/base64.h>
  3. END_HEADER
  4. BEGIN_DEPENDENCIES
  5. depends_on:POLARSSL_BASE64_C
  6. END_DEPENDENCIES
  7. BEGIN_CASE
  8. base64_encode:src_string:dst_string:dst_buf_size:result
  9. {
  10. unsigned char src_str[1000];
  11. unsigned char dst_str[1000];
  12. size_t len = {dst_buf_size};
  13. memset(src_str, 0x00, 1000);
  14. memset(dst_str, 0x00, 1000);
  15. strcpy( (char *) src_str, {src_string} );
  16. TEST_ASSERT( base64_encode( dst_str, &len, src_str, strlen( (char *) src_str ) ) == {result} );
  17. if( {result} == 0 )
  18. {
  19. TEST_ASSERT( strcmp( (char *) dst_str, {dst_string} ) == 0 );
  20. }
  21. }
  22. END_CASE
  23. BEGIN_CASE
  24. base64_decode:src_string:dst_string:result
  25. {
  26. unsigned char src_str[1000];
  27. unsigned char dst_str[1000];
  28. size_t len = 1000;
  29. int res;
  30. memset(src_str, 0x00, 1000);
  31. memset(dst_str, 0x00, 1000);
  32. strcpy( (char *) src_str, {src_string} );
  33. TEST_ASSERT( res = base64_decode( dst_str, &len, src_str, strlen( (char *) src_str ) ) == {result} );
  34. if( {result} == 0 )
  35. {
  36. TEST_ASSERT( strcmp( (char *) dst_str, {dst_string} ) == 0 );
  37. }
  38. }
  39. END_CASE
  40. BEGIN_CASE
  41. base64_selftest:
  42. {
  43. TEST_ASSERT( base64_self_test( 0 ) == 0 );
  44. }
  45. END_CASE