xref: /aosp_15_r20/external/regex-re2/util/test.cc (revision ccdc9c3e24c519bfa4832a66aa2e83a52c19f295)
1 // Copyright 2009 The RE2 Authors.  All Rights Reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4 
5 #include <stdio.h>
6 
7 #include "util/test.h"
8 
9 DEFINE_string(test_tmpdir, "/var/tmp", "temp directory");
10 
11 struct Test {
12   void (*fn)(void);
13   const char *name;
14 };
15 
16 static Test tests[10000];
17 static int ntests;
18 
RegisterTest(void (* fn)(void),const char * name)19 void RegisterTest(void (*fn)(void), const char *name) {
20   tests[ntests].fn = fn;
21   tests[ntests++].name = name;
22 }
23 
main(int argc,char ** argv)24 int main(int argc, char** argv) {
25   for (int i = 0; i < ntests; i++) {
26     printf("%s\n", tests[i].name);
27     tests[i].fn();
28   }
29   printf("PASS\n");
30   return 0;
31 }
32