The Poor Man's (or Woman's) Intrusion Detection System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.7 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // Test Jig
  3. // Written by Jonathan A. Foster <ChipMaster@YeOlPiShack.net>
  4. // Started June 28th, 2021
  5. // Copyright 2021 JF Possibilities, Inc. All Rights Reserved
  6. // Included by permission from JF Possibilities, Inc.
  7. //
  8. // Simple framework for running tests and reporting. Mostly this is an
  9. // output formatter but also tracks stats on the tests reported to it.
  10. //////////////////////////////////////////////////////////////////////
  11. #include <string>
  12. #include <vector>
  13. //////////////////////////////////////////////////////////////////////
  14. // Pretty basic mechanism of formatting test output and performing
  15. // pass / fail accounting.
  16. //////////////////////////////////////////////////////////////////////
  17. struct TestIt {
  18. int count; // total count of calls to test()
  19. int passes; // total test() calls that matched
  20. std::vector<std::string> fails; // list of test titles that failed
  21. TestIt(): count(0), passes(0) {};
  22. void module(const std::string &title);// Start a new test module
  23. bool test(const std::string &title, int result, int match); // Record test result
  24. int report(); // Print summary report and return: 0 passed, 2 some failed, 3 compete fail, suitable for return from main()
  25. };
  26. //////////////////////////////////////////////////////////////////////
  27. // VT100 terminal control code constants
  28. //
  29. // Probably should learn to use termcap / curses.
  30. //
  31. // COLORS!
  32. //////////////////////////////////////////////////////////////////////
  33. namespace vt100 {
  34. const std::string
  35. RED = "\e[31;1m",
  36. YLW = "\e[33;1m",
  37. GRN = "\e[32m",
  38. GRY = "\e[2m",
  39. CYN = "\e[36m",
  40. RST = "\e[0m";
  41. }