Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Compiler to use - can be replaced by clang for instance
  2. CC := gcc
  3. # Number of random text expressions to generate, for random testing
  4. NRAND_TESTS := 1000
  5. # Flags to pass to compiler
  6. CFLAGS := -Os -Wall -Wextra -std=c99 -I.
  7. all:
  8. @$(CC) $(CFLAGS) re.c tests/test1.c -o tests/test1
  9. @$(CC) $(CFLAGS) re.c tests/test2.c -o tests/test2
  10. @$(CC) $(CFLAGS) re.c tests/test_rand.c -o tests/test_rand
  11. clean:
  12. @rm -f tests/test1 tests/test2 tests/test_rand
  13. @#@$(foreach test_bin,$(TEST_BINS), rm -f $(test_bin) ; )
  14. @rm -f a.out
  15. @rm -f *.o
  16. test: all
  17. @echo
  18. @echo Testing hand-picked regex\'s:
  19. @./tests/test1
  20. @echo Testing patterns against $(NRAND_TESTS) random strings matching the Python implementation and comparing:
  21. @echo
  22. @python ./scripts/regex_test.py \\d+\\w?\\D\\d $(NRAND_TESTS)
  23. @python ./scripts/regex_test.py \\s+[a-zA-Z0-9?]* $(NRAND_TESTS)
  24. @python ./scripts/regex_test.py \\w*\\d?\\w\\? $(NRAND_TESTS)
  25. @#python ./scripts/regex_test.py [^\\d]+\\\\?\\s $(NRAND_TESTS)
  26. @#python ./scripts/regex_test.py [^\\w][^-1-4] $(NRAND_TESTS)
  27. @#python ./scripts/regex_test.py [^\\w] $(NRAND_TESTS)
  28. @#python ./scripts/regex_test.py [^1-4] $(NRAND_TESTS)
  29. @#python ./scripts/regex_test.py [^-1-4] $(NRAND_TESTS)
  30. @#python ./scripts/regex_test.py [^\\d]+\\s?[\\w]* $(NRAND_TESTS)
  31. @python ./scripts/regex_test.py a+b*[ac]*.+.*.[\\.]. $(NRAND_TESTS)
  32. @python ./scripts/regex_test.py a?b[ac*]*.?[\\]+[?]? $(NRAND_TESTS)
  33. @#python ./scripts/regex_test.py [1-5-]+[-1-2]-[-] $(NRAND_TESTS)
  34. @python ./scripts/regex_test.py [-1-3]-[-]+ $(NRAND_TESTS)
  35. @python ./scripts/regex_test.py [1-5]+[-1-2]-[\\-] $(NRAND_TESTS)
  36. @python ./scripts/regex_test.py [-1-2]* $(NRAND_TESTS)
  37. @python ./scripts/regex_test.py \\s?[a-fKL098]+-? $(NRAND_TESTS)
  38. @python ./scripts/regex_test.py [\\-]* $(NRAND_TESTS)
  39. @python ./scripts/regex_test.py [\\\\]+ $(NRAND_TESTS)
  40. @python ./scripts/regex_test.py [0-9a-fA-F]+ $(NRAND_TESTS)
  41. @python ./scripts/regex_test.py [1379][2468][abcdef] $(NRAND_TESTS)
  42. @python ./scripts/regex_test.py [012345-9]?[0123-789] $(NRAND_TESTS)
  43. @python ./scripts/regex_test.py [012345-9] $(NRAND_TESTS)
  44. @python ./scripts/regex_test.py [0-56789] $(NRAND_TESTS)
  45. @python ./scripts/regex_test.py [abc-zABC-Z] $(NRAND_TESTS)
  46. @python ./scripts/regex_test.py [a\d]?1234 $(NRAND_TESTS)
  47. @python ./scripts/regex_test.py .*123faerdig $(NRAND_TESTS)
  48. @python ./scripts/regex_test.py .?\\w+jsj$ $(NRAND_TESTS)
  49. @python ./scripts/regex_test.py [?to][+to][?ta][*ta] $(NRAND_TESTS)
  50. @#python ./scripts/regex_test.py [^-1-4] $(NRAND_TESTS)
  51. @echo
  52. @echo
  53. @./tests/test2
  54. @echo
  55. @echo