Repository navigation
Expand file tree
/
Copy pathtests.cpp
More file actions
659 lines (570 loc) · 23 KB
/
Copy pathtests.cpp
File metadata and controls
659 lines (570 loc) · 23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
// tests.cpp — Unit tests + benchmark harness for piecetable-editor
//
// Build: make test
// Run: ./bin/test
//
// This file is intentionally structured so each section can be read
// independently by a recruiter or reviewer scanning the code.
#include <cassert>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <string>
#include <sstream>
#include "PieceTable.hpp"
#include "GapBuffer.hpp"
#include "TextDocument.hpp"
#include "TextEditor.hpp"
#include "DiffEngine.hpp"
#include "VersionHistory.hpp"
#include "SyntaxHighlighter.hpp"
#include "RegexEngine.hpp"
// ============================================================================
// Helpers
// ============================================================================
// Returns elapsed time in milliseconds for calling fn() `iters` times.
template <typename F>
double measure_ms(F&& fn, int iters = 1) {
auto t0 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < iters; ++i) fn();
auto t1 = std::chrono::high_resolution_clock::now();
return std::chrono::duration<double, std::milli>(t1 - t0).count();
}
static int tests_run = 0, tests_passed = 0;
#define RUN_TEST(fn) do { \
++tests_run; \
fn(); \
++tests_passed; \
std::cout << " [PASS] " #fn "\n"; \
} while (0)
// ============================================================================
// PieceTable
// ============================================================================
void test_piece_table_insert() {
PieceTable pt;
pt.insert(0, "Hello");
pt.insert(5, " World");
assert(pt.text() == "Hello World");
}
void test_piece_table_erase() {
PieceTable pt;
pt.insert(0, "Hello World");
pt.erase(5, 1);
assert(pt.text() == "HelloWorld");
}
void test_piece_table_midstream_insert_and_erase() {
PieceTable pt;
pt.insert(0, "ACE");
pt.insert(1, "B"); // -> ABCE
pt.insert(3, "D"); // -> ABCDE
assert(pt.text() == "ABCDE");
pt.erase(2, 2); // remove "CD" -> ABE
assert(pt.text() == "ABE");
}
// ============================================================================
// GapBuffer — correctness
// ============================================================================
void test_gapbuffer_append_sequential() {
GapBuffer gb;
for (char c : std::string("Hello World"))
gb.insert(gb.size(), std::string(1, c));
assert(gb.text() == "Hello World");
}
void test_gapbuffer_insert_at_beginning() {
GapBuffer gb;
gb.insert(0, "World");
gb.insert(0, "Hello ");
assert(gb.text() == "Hello World");
}
void test_gapbuffer_insert_in_middle() {
GapBuffer gb;
gb.insert(0, "ACE");
gb.insert(1, "B"); // ABCE
gb.insert(3, "D"); // ABCDE
assert(gb.text() == "ABCDE");
}
void test_gapbuffer_erase_front() {
GapBuffer gb;
gb.insert(0, "Hello World");
gb.erase(0, 6); // remove "Hello "
assert(gb.text() == "World");
}
void test_gapbuffer_erase_middle() {
GapBuffer gb;
gb.insert(0, "Hello World");
gb.erase(5, 1); // remove space
assert(gb.text() == "HelloWorld");
}
void test_gapbuffer_erase_then_insert() {
GapBuffer gb;
gb.insert(0, "aXb");
gb.erase(1, 1); // "ab"
gb.insert(1, "c"); // "acb"
assert(gb.text() == "acb");
}
void test_gapbuffer_charAt() {
GapBuffer gb;
gb.insert(0, "Hello");
assert(gb.charAt(0) == 'H');
assert(gb.charAt(4) == 'o');
}
void test_gapbuffer_size() {
GapBuffer gb;
gb.insert(0, "abc");
assert(gb.size() == 3);
gb.erase(1, 1);
assert(gb.size() == 2);
}
void test_gapbuffer_empty_string_insert() {
GapBuffer gb;
gb.insert(0, ""); // must not crash or change state
assert(gb.size() == 0);
}
void test_gapbuffer_insert_past_end() {
GapBuffer gb;
gb.insert(0, "abc");
gb.insert(9999, "X"); // should clamp to end
assert(gb.text() == "abcX");
}
// ============================================================================
// TextDocument
// ============================================================================
void test_document_insert_char() {
TextDocument doc;
doc.appendLine("Hello");
doc.insertChar(0, 5, '!');
assert(doc.lineText(0) == "Hello!");
}
void test_document_newline_split() {
TextDocument doc;
doc.appendLine("HelloWorld");
doc.insertNewline(0, 5);
assert(doc.lineText(0) == "Hello");
assert(doc.lineText(1) == "World");
}
void test_document_merge_lines() {
TextDocument doc;
doc.appendLine("Hello");
doc.appendLine("World");
doc.mergeWithNextLine(0);
assert(doc.lineText(0) == "HelloWorld");
}
void test_document_line_starts_stay_correct_after_many_edits() {
TextDocument doc;
for (char c : std::string("abc")) doc.insertChar(0, doc.lineLength(0), c);
doc.insertNewline(0, 1); // "a" | "bc"
for (char c : std::string("XY")) doc.insertChar(1, doc.lineLength(1), c);
assert(doc.lineCount() == 2);
assert(doc.lineText(0) == "a");
assert(doc.lineText(1) == "bcXY");
doc.mergeWithNextLine(0);
assert(doc.lineCount() == 1);
assert(doc.lineText(0) == "abcXY");
}
void test_row_col_to_offset() {
TextDocument doc;
doc.appendLine("abc");
doc.appendLine("def");
// "abc\ndef" -> offset of 'f' is 6
assert(doc.toOffset(1, 2) == 6);
}
// ============================================================================
// TextEditor: undo/redo, search
// ============================================================================
void test_undo_insert() {
TextEditor editor;
editor.insertCharacter('H');
editor.insertCharacter('i');
editor.undo();
assert(editor.lineText(0) == "H");
editor.undo();
assert(editor.lineText(0) == "");
}
void test_undo_then_redo() {
TextEditor editor;
editor.insertCharacter('A');
editor.insertCharacter('B');
editor.undo();
editor.redo();
assert(editor.lineText(0) == "AB");
}
void test_search_finds_all_matches() {
TextEditor editor;
editor.testAppendLine("hello world");
editor.testAppendLine("world hello");
editor.testSetSearchQuery("world");
assert(editor.testMatchCount() == 2);
}
// ============================================================================
// DiffEngine (LCS-based line diff)
// ============================================================================
void test_diff_detects_pure_addition() {
auto diff = DiffEngine::diffLines({"a", "b"}, {"a", "b", "c"});
int added = 0;
for (auto& d : diff) if (d.op == DiffOp::Added) added++;
assert(added == 1);
}
void test_diff_detects_pure_removal() {
auto diff = DiffEngine::diffLines({"a", "b", "c"}, {"a", "c"});
int removed = 0;
for (auto& d : diff) if (d.op == DiffOp::Removed) removed++;
assert(removed == 1);
}
void test_diff_identical_inputs_are_all_unchanged() {
auto diff = DiffEngine::diffLines({"x", "y", "z"}, {"x", "y", "z"});
for (auto& d : diff) assert(d.op == DiffOp::Unchanged);
assert(diff.size() == 3);
}
void test_version_history_diff_against_latest() {
VersionHistory history;
history.recordSnapshot("line1\nline2\n");
auto diff = history.diffAgainstLatest("line1\nline2\nline3\n");
int added = 0;
for (auto& d : diff) if (d.op == DiffOp::Added) added++;
assert(added == 1);
}
// ============================================================================
// Selection / Clipboard (via TextEditor's public API)
// ============================================================================
void test_copy_paste_round_trip() {
TextEditor editor;
editor.testAppendLine("hello world");
editor.beginSelection();
editor.extendSelectionTo(0, 5);
editor.copySelectionToClipboard();
editor.clearSelection();
editor.pasteFromClipboard();
assert(editor.lineText(0).substr(0, 5) == "hello");
}
// ============================================================================
// SyntaxHighlighter
// ============================================================================
void test_syntax_cpp_keyword() {
bool inBlock = false;
auto toks = SyntaxHighlighter::tokenize(
"int main() {", SyntaxHighlighter::Language::Cpp, inBlock);
bool foundKw = false;
for (auto& t : toks)
if (t.type == TokenType::Keyword) { foundKw = true; break; }
assert(foundKw && "Expected 'int' to be highlighted as keyword");
}
void test_syntax_cpp_line_comment() {
bool inBlock = false;
auto toks = SyntaxHighlighter::tokenize(
"int x; // a comment", SyntaxHighlighter::Language::Cpp, inBlock);
bool foundComment = false;
for (auto& t : toks)
if (t.type == TokenType::Comment) { foundComment = true; break; }
assert(foundComment);
}
void test_syntax_cpp_block_comment_span() {
// Line 1 opens a block comment, line 2 should be classified as Comment.
bool inBlock = false;
SyntaxHighlighter::tokenize("/* open", SyntaxHighlighter::Language::Cpp, inBlock);
assert(inBlock && "Block comment should still be open after line 1");
auto toks2 = SyntaxHighlighter::tokenize(
"still in comment", SyntaxHighlighter::Language::Cpp, inBlock);
bool allComment = true;
for (auto& t : toks2)
if (t.type != TokenType::Comment) { allComment = false; break; }
assert(allComment && "All tokens inside block comment must be Comment type");
}
void test_syntax_cpp_string_literal() {
bool inBlock = false;
auto toks = SyntaxHighlighter::tokenize(
"std::string s = \"hello\";", SyntaxHighlighter::Language::Cpp, inBlock);
bool foundStr = false;
for (auto& t : toks)
if (t.type == TokenType::String) { foundStr = true; break; }
assert(foundStr);
}
void test_syntax_cpp_preprocessor() {
bool inBlock = false;
auto toks = SyntaxHighlighter::tokenize(
"#include <vector>", SyntaxHighlighter::Language::Cpp, inBlock);
// Preprocessor lines are returned as a single token covering the whole line.
assert(!toks.empty() && toks[0].type == TokenType::Preprocessor);
}
void test_syntax_python_keyword() {
bool inBlock = false;
auto toks = SyntaxHighlighter::tokenize(
"def foo():", SyntaxHighlighter::Language::Python, inBlock);
bool found = false;
for (auto& t : toks)
if (t.type == TokenType::Keyword) { found = true; break; }
assert(found);
}
void test_syntax_none_language_passthrough() {
bool inBlock = false;
std::string line = "some random text";
auto toks = SyntaxHighlighter::tokenize(line, SyntaxHighlighter::Language::None, inBlock);
int total = 0;
for (auto& t : toks) total += t.length;
assert(total == (int)line.size());
}
void test_syntax_tokens_cover_entire_line() {
// Every character in the line must be covered by exactly one token.
bool inBlock = false;
std::string line = "int x = 42; /* answer */ // done";
auto toks = SyntaxHighlighter::tokenize(line, SyntaxHighlighter::Language::Cpp, inBlock);
int total = 0;
for (auto& t : toks) total += t.length;
assert(total == (int)line.size() &&
"Tokens must cover the entire line without gaps or overlaps");
}
void test_syntax_language_detection() {
assert(SyntaxHighlighter::fromFilename("editor.cpp") == SyntaxHighlighter::Language::Cpp);
assert(SyntaxHighlighter::fromFilename("editor.hpp") == SyntaxHighlighter::Language::Cpp);
assert(SyntaxHighlighter::fromFilename("script.py") == SyntaxHighlighter::Language::Python);
assert(SyntaxHighlighter::fromFilename("README.md") == SyntaxHighlighter::Language::None);
assert(SyntaxHighlighter::fromFilename("noextension") == SyntaxHighlighter::Language::None);
}
// ============================================================================
// RegexEngine (Thompson NFA)
// ============================================================================
void test_regex_literal_match() {
auto m = RegexEngine::findAll("hello", "say hello world");
assert(m.size() == 1 && m[0].col == 4 && m[0].length == 5);
}
void test_regex_dot_star() {
auto m = RegexEngine::findAll("a.*b", "xafoob");
assert(!m.empty() && m[0].col == 1 && m[0].length == 5);
}
void test_regex_plus_quantifier() {
auto m = RegexEngine::findAll("a+", "baaac");
assert(m.size() == 1 && m[0].col == 1 && m[0].length == 3);
}
void test_regex_question_quantifier() {
auto m = RegexEngine::findAll("colou?r", "The colour and the color");
// Should find both "colour" and "color".
assert(m.size() == 2);
}
void test_regex_alternation() {
auto m = RegexEngine::findAll("cat|dog", "I have a cat and a dog");
assert(m.size() == 2);
}
void test_regex_character_class() {
auto m = RegexEngine::findAll("[0-9]+", "abc 42 and 007");
assert(m.size() == 2);
assert(m[0].length == 2); // "42"
assert(m[1].length == 3); // "007"
}
void test_regex_negated_class() {
// [^aeiou]+ should match one or more consonant runs.
auto m = RegexEngine::findAll("[^aeiou ]+", "cat");
// "c" and "t" are separate consonant spans (no vowels).
assert(!m.empty());
}
void test_regex_digit_shorthand() {
auto m = RegexEngine::findAll("\\d+", "score: 1234 and 56");
assert(m.size() == 2);
assert(m[0].length == 4 && m[1].length == 2);
}
void test_regex_word_shorthand() {
auto m = RegexEngine::findAll("\\w+", "hello world");
assert(m.size() == 2);
}
void test_regex_no_match() {
auto m = RegexEngine::findAll("xyz", "hello world");
assert(m.empty());
}
void test_regex_anchored_start() {
auto m = RegexEngine::findAll("^hello", "hello world");
assert(m.size() == 1 && m[0].col == 0);
auto m2 = RegexEngine::findAll("^world", "hello world");
assert(m2.empty());
}
void test_regex_anchored_end() {
auto m = RegexEngine::findAll("world$", "hello world");
assert(m.size() == 1);
auto m2 = RegexEngine::findAll("hello$", "hello world");
assert(m2.empty());
}
void test_regex_grouping() {
// (ab)+ should match one or more repetitions of "ab".
auto m = RegexEngine::findAll("(ab)+", "ababab");
assert(!m.empty() && m[0].col == 0 && m[0].length == 6);
}
void test_regex_validity_check() {
assert(RegexEngine::isValid("a+b"));
assert(RegexEngine::isValid("[a-z]+"));
// Empty pattern is trivially valid.
assert(RegexEngine::isValid(""));
}
void test_regex_string_empty() {
auto m = RegexEngine::findAll("abc", "");
assert(m.empty());
}
// ============================================================================
// Benchmark: PieceTable vs GapBuffer across 4 workloads
//
// The four scenarios capture the trade-off between the two structures:
//
// Scenario A — Sequential append (cursor always at end):
// GapBuffer wins: O(k) insert with zero memory movement.
//
// Scenario B — Random-position insert:
// PieceTable wins: each insert is O(log n) fragment lookup + O(k) copy;
// GapBuffer must move O(n) chars to reposition the gap.
//
// Scenario C — Sequential erase:
// GapBuffer wins: erase-at-gap is O(1).
//
// Scenario D — Alternating front/back insert ("ping-pong"):
// PieceTable wins: GapBuffer must traverse the entire document every other
// insert; PieceTable never moves any text, just adds a piece record.
//
// Results are printed to stdout as a Markdown table.
// ============================================================================
struct BenchResult { std::string scenario; double ptMs; double gbMs; };
std::string winner(double ptMs, double gbMs) {
if (ptMs < gbMs * 0.9) return "PieceTable";
if (gbMs < ptMs * 0.9) return "GapBuffer";
return "~tie~";
}
void run_benchmark(std::vector<BenchResult>& results) {
constexpr int N = 50'000;
// ── Scenario A: sequential append ────────────────────────────────────────
{
PieceTable pt;
double ptMs = measure_ms([&]{ pt.insert(pt.size(), "a"); }, N);
GapBuffer gb;
double gbMs = measure_ms([&]{ gb.insert(gb.size(), "a"); }, N);
results.push_back({"A: Sequential append", ptMs, gbMs});
assert(pt.size() == N);
assert(gb.size() == N);
}
// ── Scenario B: random-position insert ───────────────────────────────────
{
PieceTable pt;
double ptMs = measure_ms([&]{
size_t pos = (pt.size() == 0) ? 0 : (pt.size() / 2);
pt.insert(pos, "a");
}, N);
GapBuffer gb;
double gbMs = measure_ms([&]{
size_t pos = (gb.size() == 0) ? 0 : (gb.size() / 2);
gb.insert(pos, "a");
}, N);
results.push_back({"B: Random-position insert (mid)", ptMs, gbMs});
}
// ── Scenario C: sequential erase from front ───────────────────────────────
{
PieceTable pt;
for (int i = 0; i < N; ++i) pt.insert(pt.size(), "a");
double ptMs = measure_ms([&]{ if (pt.size() > 0) pt.erase(0, 1); }, N);
GapBuffer gb;
for (int i = 0; i < N; ++i) gb.insert(gb.size(), "a");
double gbMs = measure_ms([&]{ if (gb.size() > 0) gb.erase(0, 1); }, N);
results.push_back({"C: Sequential erase (from front)", ptMs, gbMs});
}
// ── Scenario D: alternating front/back insert (ping-pong) ────────────────
{
PieceTable pt;
bool front = true;
double ptMs = measure_ms([&]{
pt.insert(front ? 0 : pt.size(), "a");
front = !front;
}, N);
GapBuffer gb;
front = true;
double gbMs = measure_ms([&]{
gb.insert(front ? 0 : gb.size(), "a");
front = !front;
}, N);
results.push_back({"D: Alternating front/back (ping-pong)", ptMs, gbMs});
}
}
void print_benchmark_table(const std::vector<BenchResult>& results) {
// Print as a Markdown table.
std::cout << "\n### PieceTable vs GapBuffer Benchmark ("
<< "N=50,000 operations each)\n\n";
std::cout << "| Scenario | PieceTable (ms) | GapBuffer (ms) | Winner |\n";
std::cout << "|-------------------------------------|:----------------:|:---------------:|:------------:|\n";
for (auto& r : results) {
std::ostringstream oss;
oss << "| " << std::left << std::setw(37) << r.scenario
<< "| " << std::right << std::setw(16) << std::fixed << std::setprecision(2) << r.ptMs
<< " | " << std::setw(15) << r.gbMs
<< " | " << std::setw(12) << winner(r.ptMs, r.gbMs) << " |\n";
std::cout << oss.str();
}
std::cout << "\n(Lower is faster. Winner declared when ≥10% faster.)\n\n";
}
// ============================================================================
// main
// ============================================================================
int main() {
// ── PieceTable ────────────────────────────────────────────────────────────
std::cout << "[PieceTable]\n";
RUN_TEST(test_piece_table_insert);
RUN_TEST(test_piece_table_erase);
RUN_TEST(test_piece_table_midstream_insert_and_erase);
// ── GapBuffer ─────────────────────────────────────────────────────────────
std::cout << "\n[GapBuffer]\n";
RUN_TEST(test_gapbuffer_append_sequential);
RUN_TEST(test_gapbuffer_insert_at_beginning);
RUN_TEST(test_gapbuffer_insert_in_middle);
RUN_TEST(test_gapbuffer_erase_front);
RUN_TEST(test_gapbuffer_erase_middle);
RUN_TEST(test_gapbuffer_erase_then_insert);
RUN_TEST(test_gapbuffer_charAt);
RUN_TEST(test_gapbuffer_size);
RUN_TEST(test_gapbuffer_empty_string_insert);
RUN_TEST(test_gapbuffer_insert_past_end);
// ── TextDocument ──────────────────────────────────────────────────────────
std::cout << "\n[TextDocument]\n";
RUN_TEST(test_document_insert_char);
RUN_TEST(test_document_newline_split);
RUN_TEST(test_document_merge_lines);
RUN_TEST(test_document_line_starts_stay_correct_after_many_edits);
RUN_TEST(test_row_col_to_offset);
// ── TextEditor ────────────────────────────────────────────────────────────
std::cout << "\n[TextEditor]\n";
RUN_TEST(test_undo_insert);
RUN_TEST(test_undo_then_redo);
RUN_TEST(test_search_finds_all_matches);
// ── DiffEngine / VersionHistory ───────────────────────────────────────────
std::cout << "\n[DiffEngine / VersionHistory]\n";
RUN_TEST(test_diff_detects_pure_addition);
RUN_TEST(test_diff_detects_pure_removal);
RUN_TEST(test_diff_identical_inputs_are_all_unchanged);
RUN_TEST(test_version_history_diff_against_latest);
// ── Selection / Clipboard ─────────────────────────────────────────────────
std::cout << "\n[Selection / Clipboard]\n";
RUN_TEST(test_copy_paste_round_trip);
// ── SyntaxHighlighter ─────────────────────────────────────────────────────
std::cout << "\n[SyntaxHighlighter]\n";
RUN_TEST(test_syntax_cpp_keyword);
RUN_TEST(test_syntax_cpp_line_comment);
RUN_TEST(test_syntax_cpp_block_comment_span);
RUN_TEST(test_syntax_cpp_string_literal);
RUN_TEST(test_syntax_cpp_preprocessor);
RUN_TEST(test_syntax_python_keyword);
RUN_TEST(test_syntax_none_language_passthrough);
RUN_TEST(test_syntax_tokens_cover_entire_line);
RUN_TEST(test_syntax_language_detection);
// ── RegexEngine ───────────────────────────────────────────────────────────
std::cout << "\n[RegexEngine — Thompson NFA]\n";
RUN_TEST(test_regex_literal_match);
RUN_TEST(test_regex_dot_star);
RUN_TEST(test_regex_plus_quantifier);
RUN_TEST(test_regex_question_quantifier);
RUN_TEST(test_regex_alternation);
RUN_TEST(test_regex_character_class);
RUN_TEST(test_regex_negated_class);
RUN_TEST(test_regex_digit_shorthand);
RUN_TEST(test_regex_word_shorthand);
RUN_TEST(test_regex_no_match);
RUN_TEST(test_regex_anchored_start);
RUN_TEST(test_regex_anchored_end);
RUN_TEST(test_regex_grouping);
RUN_TEST(test_regex_validity_check);
RUN_TEST(test_regex_string_empty);
std::cout << "\n[Benchmarks]\n";
std::vector<BenchResult> bench;
run_benchmark(bench);
print_benchmark_table(bench);
std::cout << "All " << tests_passed << "/" << tests_run << " tests passed!\n";
return 0;
}