test_bom.c 810 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include "bom.h"
  4. char *fileWithBOM = "./testBOM";
  5. char *fileWithoutBOM = "./testNoBOM";
  6. void testCheckBOM(void) {
  7. assert(HASBOM == checkBOM(fileWithBOM));
  8. assert(NOBOM == checkBOM(fileWithoutBOM));
  9. }
  10. char *fileBOMRemoval = "./testRemove";
  11. void testRemoveBOM(void) {
  12. int result = removeBOM(fileBOMRemoval);
  13. assert(ERROR != result);
  14. assert(SUCCESS == result);
  15. assert(NOBOM == checkBOM(fileBOMRemoval));
  16. }
  17. char *fileBOMAddition = "./testAdd";
  18. void testAddBOM(void) {
  19. int result = addBOM(fileBOMAddition);
  20. assert(ERROR != result);
  21. assert(SUCCESS == result);
  22. assert(HASBOM == checkBOM(fileBOMAddition));
  23. }
  24. int main(int argc, char **argv) {
  25. (void)argc;
  26. (void)argv;
  27. testCheckBOM();
  28. testRemoveBOM();
  29. testAddBOM();
  30. printf("OK\n");
  31. }