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.

29 lines
1.0 KiB

  1. import { descriptiveCounter } from "../descriptiveCounter";
  2. import { assert } from "./assert";
  3. let testCount: number = 0;
  4. type StringCallback = (text: string) => string;
  5. var showUnitTests = true;//window.location.href.indexOf("http") < 0;
  6. export function testDescriptiveCounter() {
  7. if (showUnitTests) {
  8. testCount = 0;
  9. start();
  10. console.log("total tests: " + testCount);
  11. }
  12. }
  13. function start() {
  14. console.log("=== descriptiveCounter ===");
  15. test(descriptiveCounter, "one blankspace", " ", "one blankspace");
  16. test(descriptiveCounter, "mixed chars", " A ", "one blankspace & one 'A' & one blankspace");
  17. test(descriptiveCounter, "4 blankspaces", " ", "four blankspaces");
  18. test(descriptiveCounter, "9 blankspaces", " ", "many blankspaces");
  19. test(descriptiveCounter, "2 As", "AA", "two 'A's");
  20. }
  21. function test(func: StringCallback, testName: string, inputs, expected: string) {
  22. let actual: string = func(inputs);
  23. assert(testName, expected, actual);
  24. testCount++;
  25. }