Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1029104 // test_LCSingleSearcher_v1_systematically

JavaX fragment (include) [tags: use-pretranspiled]

Uses 11335K of libraries. Click here for Pure Java version (9485L/61K).

svoid test_LCSingleSearcher_v1_systematically(int max, O... _) {
  optPar bool verbose;
  optPar bool checkOverlongQueries = true;
  
  for (int n = 0; n <= max; n++) {
    print("Testing length " + n);
    int tests = 0;
    for (S text : allABCCombinationsOfLength(n)) {
      //print(+text);
      for (int j = 1; j <= n+(checkOverlongQueries ? 1 : 0); j++)
        for (S query : allABCCombinationsOfLength(j)) {
          ++tests;
          Pair<L<Int>, S> output = hijackPrintWithResult(() -> {
            new LCSingleSearcher_v1 searcher;
            searcher.text = text;
            ret searcher.search(query);
          });
          L<Int> correct = indicesOf(text, query);
          L<Int> out = sorted(output.a);
          if (eq(correct, out)) {
            if (verbose) print("OK " + query + " in " + text + ": " + out);
          } else {
            print(output);
            fail(query + " in " + text + ": " + out + " / " + correct);
          }
        }
    }
    print(nTests(tests) + " done");
  }
}

Author comment

Began life as a copy of #1029101

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029104
Snippet name: test_LCSingleSearcher_v1_systematically
Eternal ID of this version: #1029104/11
Text MD5: 8a6ebbc419cec66c5d6a8b356eb335b7
Transpilation MD5: 427f332dc85f6f1a3ff7a39c3f45d6a9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-20 13:11:40
Source code size: 1053 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 230 / 337
Version history: 10 change(s)
Referenced in: [show references]