daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. programmatically mocking a function
  2. #include <stdio.h>
  3.  
  4. void someFunc( void )
  5. {
  6.     printf("%s():%dn",__func__,__LINE__);
  7. }
  8.  
  9. void someBlah( void )
  10. {
  11.     printf("%s():%dn",__func__,__LINE__);
  12. }
  13.  
  14. int main(void)
  15. {
  16.     someFunc();
  17. }
  18.    
  19. #define BLAH 0
  20. #define FOO 1
  21. void (*table_function[])(void) = {someBlah, someFoo};
  22.    
  23. table_function[BLAH]();
  24.    
  25. table_function[BLAH] = otherBlah;
  26.    
  27. #include <stdio.h>
  28. #define DEBUG
  29.  
  30. void someFunc( void )
  31. {
  32. #ifndef DEBUG
  33.     printf("%s():%dn",__func__,__LINE__);
  34. #else
  35.     printf("%s():%dn",__func__,__LINE__);
  36. #endif
  37. }
  38.  
  39. int main(void)
  40. {
  41.     someFunc();
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top