test_bom.c 734 B

123456789101112131415161718192021222324252627282930313233343536
  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(SUCCESS == result);
  14. assert(NOBOM == checkBOM(fileBOMRemoval));
  15. }
  16. char *fileBOMAddition = "./testAdd";
  17. void testAddBOM(void) {
  18. int result = addBOM(fileBOMAddition);
  19. assert(SUCCESS == result);
  20. assert(HASBOM == checkBOM(fileBOMAddition));
  21. }
  22. int main(int argc, char **argv) {
  23. (void)argc;
  24. (void)argv;
  25. testCheckBOM();
  26. testRemoveBOM();
  27. testAddBOM();
  28. printf("OK\n");
  29. }