File: 03_catchv2_3.patch

package info (click to toggle)
nmodl 0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,016 kB
  • sloc: cpp: 28,492; javascript: 9,841; yacc: 2,804; python: 1,971; lex: 1,674; xml: 181; sh: 136; ansic: 37; makefile: 17; pascal: 7
file content (1443 lines) | stat: -rw-r--r-- 60,288 bytes parent folder | download | duplicates (2)
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
From 74d7dbe996d00301635cf701559f60ba20bbd426 Mon Sep 17 00:00:00 2001
From: Nicolas Cornu <nicolas.cornu@epfl.ch>
Date: Fri, 19 May 2023 15:25:16 +0200
Subject: [PATCH] Update Catch 2 to a v3 version (#973)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@
 # =============================================================================
 option(NMODL_ENABLE_PYTHON_BINDINGS "Enable pybind11 based python bindings" ON)
 option(NMODL_ENABLE_LEGACY_UNITS "Use original faraday, R, etc. instead of 2019 nist constants" OFF)
+option(NMODL_ENABLE_TESTS "Enable build of tests" ON)
 if(NMODL_ENABLE_LEGACY_UNITS)
   add_definitions(-DUSE_LEGACY_UNITS)
 endif()
@@ -105,13 +106,6 @@
 # =============================================================================
 set(NMODL_3RDPARTY_DIR ext)
 include(${HPC_CODING_CONVENTIONS_DIR}/cpp/cmake/3rdparty.cmake)
-cpp_cc_git_submodule(catch2 BUILD PACKAGE Catch2 REQUIRED)
-if(NMODL_3RDPARTY_USE_CATCH2)
-  # If we're using the submodule then make sure the Catch.cmake helper can be found. In newer
-  # versions of Catch2, and with hpc-coding-conventions#130, this should just work...
-  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/catch2/contrib")
-endif()
-include(Catch)
 # If we're being built as a submodule of CoreNEURON then CoreNEURON may have already found/loaded a
 # CLI11 submodule.
 if(NOT TARGET CLI11::CLI11)
@@ -212,7 +206,14 @@
                                  --track-origins=yes \
                                  --show-possibly-lost=no")
 # do not enable tests if nmodl is used as submodule
-if(NOT NMODL_AS_SUBPROJECT)
+if(NOT NMODL_AS_SUBPROJECT AND NMODL_ENABLE_TESTS)
+  cpp_cc_git_submodule(catch2 BUILD PACKAGE Catch2 REQUIRED)
+  if(NMODL_3RDPARTY_USE_CATCH2)
+    # If we're using the submodule then make sure the Catch.cmake helper can be found. In newer
+    # versions of Catch2, and with hpc-coding-conventions#130, this should just work...
+    list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/catch2/extras")
+  endif()
+  include(Catch)
   include(CTest)
   add_subdirectory(test/unit)
   add_subdirectory(test/integration)
@@ -278,6 +279,7 @@
 message(STATUS "Flex                | ${FLEX_EXECUTABLE}")
 message(STATUS "Bison               | ${BISON_EXECUTABLE}")
 message(STATUS "Python              | ${PYTHON_EXECUTABLE}")
+message(STATUS "  Linked against    | ${LINK_AGAINST_PYTHON}")
 message(STATUS "--------------+--------------------------------------------------------------")
 message(STATUS " See documentation : https://github.com/BlueBrain/nmodl/")
 message(STATUS "--------------+--------------------------------------------------------------")
--- a/setup.py
+++ b/setup.py
@@ -107,6 +107,7 @@
 cmake_args = ["-DPYTHON_EXECUTABLE=" + sys.executable]
 if "bdist_wheel" in sys.argv:
     cmake_args.append("-DLINK_AGAINST_PYTHON=FALSE")
+    cmake_args.append("-DNMODL_ENABLE_TESTS=FALSE")
 
 # For CI, we want to build separate wheel
 package_name = "NMODL"
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -71,41 +71,41 @@
   codegen/main.cpp codegen/codegen_helper.cpp codegen/codegen_utils.cpp
   codegen/codegen_cpp_visitor.cpp codegen/transform.cpp codegen/codegen_compatibility_visitor.cpp)
 
-target_link_libraries(testmodtoken lexer util)
-target_link_libraries(testlexer lexer util)
+target_link_libraries(testmodtoken PRIVATE lexer util)
+target_link_libraries(testlexer PRIVATE lexer util)
 target_link_libraries(
   testparser
-  visitor
-  symtab
-  lexer
-  util
-  test_util
-  printer
-  ${NMODL_WRAPPER_LIBS})
+  PRIVATE visitor
+          symtab
+          lexer
+          util
+          test_util
+          printer
+          ${NMODL_WRAPPER_LIBS})
 target_link_libraries(
   testvisitor
-  visitor
-  symtab
-  lexer
-  util
-  test_util
-  printer
-  codegen
-  ${NMODL_WRAPPER_LIBS})
+  PRIVATE visitor
+          symtab
+          lexer
+          util
+          test_util
+          printer
+          codegen
+          ${NMODL_WRAPPER_LIBS})
 target_link_libraries(
   testcodegen
-  codegen
-  visitor
-  symtab
-  lexer
-  util
-  test_util
-  printer
-  ${NMODL_WRAPPER_LIBS})
-target_link_libraries(testprinter printer util)
-target_link_libraries(testsymtab symtab lexer util)
-target_link_libraries(testunitlexer lexer util)
-target_link_libraries(testunitparser lexer test_util config)
+  PRIVATE codegen
+          visitor
+          symtab
+          lexer
+          util
+          test_util
+          printer
+          ${NMODL_WRAPPER_LIBS})
+target_link_libraries(testprinter PRIVATE printer util)
+target_link_libraries(testsymtab PRIVATE symtab lexer util)
+target_link_libraries(testunitlexer PRIVATE lexer util)
+target_link_libraries(testunitparser PRIVATE lexer test_util config)
 
 # =============================================================================
 # Use catch_discover instead of add_test for granular test result reporting.
@@ -118,6 +118,22 @@
        "NMODL_WRAPLIB=${PROJECT_BINARY_DIR}/lib/nmodl/libpywrapper${CMAKE_SHARED_LIBRARY_SUFFIX}")
 endif()
 
+# Without main from Catch2
+target_link_libraries(testcodegen PRIVATE Catch2::Catch2)
+target_link_libraries(testvisitor PRIVATE Catch2::Catch2)
+
+# With main from Catch2
+target_link_libraries(testmodtoken PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testlexer PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testparser PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testprinter PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testsymtab PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testnewton PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testcrout PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testfast_math PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testunitlexer PRIVATE Catch2::Catch2WithMain)
+target_link_libraries(testunitparser PRIVATE Catch2::Catch2WithMain)
+
 foreach(
   test_name
   testcodegen
@@ -133,7 +149,6 @@
   testunitlexer
   testunitparser)
 
-  target_link_libraries(${test_name} Catch2::Catch2)
   cpp_cc_configure_sanitizers(TARGET ${test_name})
   set(env ${test_env})
   list(APPEND env ${${test_name}_env})
--- a/test/unit/codegen/codegen_compatibility_visitor.cpp
+++ b/test/unit/codegen/codegen_compatibility_visitor.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "codegen/codegen_compatibility_visitor.hpp"
@@ -14,7 +15,7 @@
 #include "visitors/perf_visitor.hpp"
 #include "visitors/symtab_visitor.hpp"
 
-using Catch::Matchers::Contains;  // ContainsSubstring in newer Catch2
+using Catch::Matchers::ContainsSubstring;
 
 using namespace nmodl;
 using namespace visitor;
--- a/test/unit/codegen/codegen_cpp_visitor.cpp
+++ b/test/unit/codegen/codegen_cpp_visitor.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "codegen/codegen_acc_visitor.hpp"
@@ -21,7 +22,7 @@
 #include "visitors/sympy_solver_visitor.hpp"
 #include "visitors/symtab_visitor.hpp"
 
-using Catch::Matchers::Contains;  // ContainsSubstring in newer Catch2
+using Catch::Matchers::ContainsSubstring;
 
 using namespace nmodl;
 using namespace visitor;
@@ -148,7 +149,7 @@
             )";
             auto const expected = reindent_text(generated_code);
             auto const result = get_instance_var_setup_function(nmodl_text);
-            REQUIRE_THAT(result, Contains(expected));
+            REQUIRE_THAT(result, ContainsSubstring(expected));
         }
     }
 
@@ -197,7 +198,7 @@
 
             auto const expected = reindent_text(generated_code);
             auto const result = get_instance_var_setup_function(nmodl_text);
-            REQUIRE_THAT(result, Contains(expected));
+            REQUIRE_THAT(result, ContainsSubstring(expected));
         }
     }
 
@@ -282,7 +283,7 @@
 
             auto const expected = reindent_text(generated_code);
             auto const result = get_instance_var_setup_function(nmodl_text);
-            REQUIRE_THAT(result, Contains(expected));
+            REQUIRE_THAT(result, ContainsSubstring(expected));
         }
     }
 }
@@ -358,9 +359,10 @@
         )";
         THEN("The instance struct should contain these variables") {
             auto const generated = get_instance_structure(nmodl_text);
-            REQUIRE_THAT(generated, Contains("double* celsius{&coreneuron::celsius}"));
-            REQUIRE_THAT(generated, Contains("double* pi{&coreneuron::pi}"));
-            REQUIRE_THAT(generated, Contains("int* secondorder{&coreneuron::secondorder}"));
+            REQUIRE_THAT(generated, ContainsSubstring("double* celsius{&coreneuron::celsius}"));
+            REQUIRE_THAT(generated, ContainsSubstring("double* pi{&coreneuron::pi}"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("int* secondorder{&coreneuron::secondorder}"));
         }
     }
     GIVEN("A MOD file that implicitly uses global variables") {
@@ -375,7 +377,7 @@
         )";
         THEN("The instance struct should contain celsius for the implicit 5th argument") {
             auto const generated = get_instance_structure(nmodl_text);
-            REQUIRE_THAT(generated, Contains("celsius"));
+            REQUIRE_THAT(generated, ContainsSubstring("celsius"));
         }
     }
     GIVEN("A MOD file that does not touch celsius, secondorder or pi") {
@@ -386,9 +388,9 @@
         )";
         THEN("The instance struct should not contain those variables") {
             auto const generated = get_instance_structure(nmodl_text);
-            REQUIRE_THAT(generated, !Contains("celsius"));
-            REQUIRE_THAT(generated, !Contains("pi"));
-            REQUIRE_THAT(generated, !Contains("secondorder"));
+            REQUIRE_THAT(generated, !ContainsSubstring("celsius"));
+            REQUIRE_THAT(generated, !ContainsSubstring("pi"));
+            REQUIRE_THAT(generated, !ContainsSubstring("secondorder"));
         }
     }
 }
@@ -430,19 +432,25 @@
         )";
         THEN("Array and global variables should be correctly generated") {
             auto const generated = get_cpp_code(nmodl_text);
-            REQUIRE_THAT(generated, Contains("double t_inf[2][201]{};"));
-            REQUIRE_THAT(generated, Contains("double t_tau[201]{};"));
+            REQUIRE_THAT(generated, ContainsSubstring("double t_inf[2][201]{};"));
+            REQUIRE_THAT(generated, ContainsSubstring("double t_tau[201]{};"));
 
-            REQUIRE_THAT(generated, Contains("inst->global->t_inf[0][i] = (inst->inf+id*2)[0];"));
-            REQUIRE_THAT(generated, Contains("inst->global->t_inf[1][i] = (inst->inf+id*2)[1];"));
-            REQUIRE_THAT(generated, Contains("inst->global->t_tau[i] = inst->global->tau;"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("inst->global->t_inf[0][i] = (inst->inf+id*2)[0];"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("inst->global->t_inf[1][i] = (inst->inf+id*2)[1];"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("inst->global->t_tau[i] = inst->global->tau;"));
 
             REQUIRE_THAT(generated,
-                         Contains("(inst->inf+id*2)[0] = inst->global->t_inf[0][index];"));
+                         ContainsSubstring("(inst->inf+id*2)[0] = inst->global->t_inf[0][index];"));
 
-            REQUIRE_THAT(generated, Contains("(inst->inf+id*2)[0] = inst->global->t_inf[0][i]"));
-            REQUIRE_THAT(generated, Contains("(inst->inf+id*2)[1] = inst->global->t_inf[1][i]"));
-            REQUIRE_THAT(generated, Contains("inst->global->tau = inst->global->t_tau[i]"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("(inst->inf+id*2)[0] = inst->global->t_inf[0][i]"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("(inst->inf+id*2)[1] = inst->global->t_inf[1][i]"));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("inst->global->tau = inst->global->t_tau[i]"));
         }
     }
     GIVEN("A MOD file with two table statements") {
@@ -499,8 +507,8 @@
             // BEFORE BREAKPOINT
             {
                 REQUIRE_THAT(generated,
-                             Contains("hoc_reg_ba(mech_type, nrn_before_after_0_ba1, "
-                                      "BAType::Before + BAType::Breakpoint);"));
+                             ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_0_ba1, "
+                                               "BAType::Before + BAType::Breakpoint);"));
                 // in case of PROTECT, there should not be simd or ivdep pragma
                 std::string generated_code = R"(
 
@@ -517,13 +525,13 @@
             }
         })";
                 auto const expected = generated_code;
-                REQUIRE_THAT(generated, Contains(expected));
+                REQUIRE_THAT(generated, ContainsSubstring(expected));
             }
             // AFTER SOLVE
             {
                 REQUIRE_THAT(generated,
-                             Contains("hoc_reg_ba(mech_type, nrn_before_after_1_ba1, BAType::After "
-                                      "+ BAType::Solve);"));
+                             ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_1_ba1, "
+                                               "BAType::After + BAType::Solve);"));
                 // in case of MUTEXLOCK/MUTEXUNLOCK, there should not be simd or ivdep pragma
                 std::string generated_code = R"(
 
@@ -542,13 +550,13 @@
             }
         })";
                 auto const expected = generated_code;
-                REQUIRE_THAT(generated, Contains(expected));
+                REQUIRE_THAT(generated, ContainsSubstring(expected));
             }
             // BEFORE INITIAL
             {
                 REQUIRE_THAT(generated,
-                             Contains("hoc_reg_ba(mech_type, nrn_before_after_2_ba1, "
-                                      "BAType::Before + BAType::Initial);"));
+                             ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_2_ba1, "
+                                               "BAType::Before + BAType::Initial);"));
                 std::string generated_code = R"(
         #pragma ivdep
         #pragma omp simd
@@ -564,13 +572,13 @@
             }
         })";
                 auto const expected = generated_code;
-                REQUIRE_THAT(generated, Contains(expected));
+                REQUIRE_THAT(generated, ContainsSubstring(expected));
             }
             // AFTER INITIAL
             {
                 REQUIRE_THAT(generated,
-                             Contains("hoc_reg_ba(mech_type, nrn_before_after_3_ba1, BAType::After "
-                                      "+ BAType::Initial);"));
+                             ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_3_ba1, "
+                                               "BAType::After + BAType::Initial);"));
                 std::string generated_code = R"(
         #pragma ivdep
         #pragma omp simd
@@ -586,13 +594,13 @@
             }
         })";
                 auto const expected = generated_code;
-                REQUIRE_THAT(generated, Contains(expected));
+                REQUIRE_THAT(generated, ContainsSubstring(expected));
             }
             // BEFORE STEP
             {
                 REQUIRE_THAT(generated,
-                             Contains("hoc_reg_ba(mech_type, nrn_before_after_4_ba1, "
-                                      "BAType::Before + BAType::Step);"));
+                             ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_4_ba1, "
+                                               "BAType::Before + BAType::Step);"));
                 std::string generated_code = R"(
         #pragma ivdep
         #pragma omp simd
@@ -608,7 +616,7 @@
             }
         })";
                 auto const expected = generated_code;
-                REQUIRE_THAT(generated, Contains(expected));
+                REQUIRE_THAT(generated, ContainsSubstring(expected));
             }
         }
     }
@@ -626,17 +634,17 @@
         THEN("They should be all registered") {
             auto const generated = get_cpp_code(nmodl_text);
             REQUIRE_THAT(generated,
-                         Contains("hoc_reg_ba(mech_type, nrn_before_after_0_ba1, BAType::Before + "
-                                  "BAType::Step);"));
+                         ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_0_ba1, "
+                                           "BAType::Before + BAType::Step);"));
             REQUIRE_THAT(generated,
-                         Contains("hoc_reg_ba(mech_type, nrn_before_after_1_ba1, BAType::After + "
-                                  "BAType::Solve);"));
+                         ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_1_ba1, "
+                                           "BAType::After + BAType::Solve);"));
             REQUIRE_THAT(generated,
-                         Contains("hoc_reg_ba(mech_type, nrn_before_after_2_ba1, BAType::Before + "
-                                  "BAType::Step);"));
+                         ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_2_ba1, "
+                                           "BAType::Before + BAType::Step);"));
             REQUIRE_THAT(generated,
-                         Contains("hoc_reg_ba(mech_type, nrn_before_after_3_ba1, BAType::After + "
-                                  "BAType::Solve);"));
+                         ContainsSubstring("hoc_reg_ba(mech_type, nrn_before_after_3_ba1, "
+                                           "BAType::After + BAType::Solve);"));
         }
     }
 }
@@ -669,7 +677,8 @@
         double kB{1.38065e-23};
         double q10Fluo{1.67};
     };)";
-            REQUIRE_THAT(generated, Contains(reindent_text(stringutils::trim(expected_code))));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring(reindent_text(stringutils::trim(expected_code))));
         }
     }
 }
@@ -683,12 +692,14 @@
         )";
         THEN("Code should be generated correctly") {
             auto const generated = get_cpp_code(nmodl_text);
-            REQUIRE_THAT(generated, Contains("double ttt_glia("));
-            REQUIRE_THAT(generated, Contains("double table_ttt_glia("));
-            REQUIRE_THAT(generated, Contains("hoc_spec_table(&inst->global->_ptable_ttt, 1"));
-            REQUIRE_THAT(generated, Contains("double uuu_glia("));
-            REQUIRE_THAT(generated, Contains("double table_uuu_glia("));
-            REQUIRE_THAT(generated, Contains("hoc_func_table(inst->global->_ptable_uuu, 2"));
+            REQUIRE_THAT(generated, ContainsSubstring("double ttt_glia("));
+            REQUIRE_THAT(generated, ContainsSubstring("double table_ttt_glia("));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("hoc_spec_table(&inst->global->_ptable_ttt, 1"));
+            REQUIRE_THAT(generated, ContainsSubstring("double uuu_glia("));
+            REQUIRE_THAT(generated, ContainsSubstring("double table_uuu_glia("));
+            REQUIRE_THAT(generated,
+                         ContainsSubstring("hoc_func_table(inst->global->_ptable_uuu, 2"));
         }
     }
 }
@@ -730,7 +741,7 @@
         for (int a = 1; a <= 10; a += 2) {
             b = b + 1.0;
         })";
-            REQUIRE_THAT(generated, Contains(expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code));
         }
     }
 }
@@ -760,7 +771,7 @@
             foo_(nt);
             &tqitem;
             pnodecount+id;)";
-            REQUIRE_THAT(generated, Contains(expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code));
         }
     }
 }
@@ -798,7 +809,7 @@
             nsb->_nsb_flag[i] = flag;
         }
     })";
-            REQUIRE_THAT(generated, Contains(cpu_net_send_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(cpu_net_send_expected_code));
             auto const gpu_generated = get_cpp_code(nmodl_text, true);
             std::string gpu_net_send_expected_code =
                 R"(static inline void net_send_buffering(const NrnThread* nt, NetSendBuffer_t* nsb, int type, int vdata_index, int weight_index, int point_index, double t, double flag) {
@@ -819,7 +830,7 @@
             nsb->_nsb_flag[i] = flag;
         }
     })";
-            REQUIRE_THAT(gpu_generated, Contains(gpu_net_send_expected_code));
+            REQUIRE_THAT(gpu_generated, ContainsSubstring(gpu_net_send_expected_code));
             std::string net_receive_kernel_expected_code =
                 R"(static inline void net_receive_kernel_(double t, Point_process* pnt, _Instance* inst, NrnThread* nt, Memb_list* ml, int weight_index, double flag) {
         int tid = pnt->_tid;
@@ -842,7 +853,7 @@
             }
         }
     })";
-            REQUIRE_THAT(generated, Contains(net_receive_kernel_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(net_receive_kernel_expected_code));
             std::string net_receive_expected_code =
                 R"(static void net_receive_(Point_process* pnt, int weight_index, double flag) {
         NrnThread* nt = nrn_threads + pnt->_tid;
@@ -858,7 +869,7 @@
         nrb->_nrb_flag[id] = flag;
         nrb->_cnt++;
     })";
-            REQUIRE_THAT(generated, Contains(net_receive_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(net_receive_expected_code));
             std::string net_buf_receive_expected_code = R"(void net_buf_receive_(NrnThread* nt) {
         Memb_list* ml = get_memb_list(nt);
         if (!ml) {
@@ -899,15 +910,15 @@
         }
         nsb->_cnt = 0;
     })";
-            REQUIRE_THAT(generated, Contains(net_buf_receive_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(net_buf_receive_expected_code));
             std::string net_init_expected_code =
                 R"(static void net_init(Point_process* pnt, int weight_index, double flag) {
         // do nothing
     })";
-            REQUIRE_THAT(generated, Contains(net_init_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(net_init_expected_code));
             std::string set_pnt_receive_expected_code =
                 "set_pnt_receive(mech_type, net_receive_, net_init, num_net_receive_args());";
-            REQUIRE_THAT(generated, Contains(set_pnt_receive_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(set_pnt_receive_expected_code));
         }
     }
     GIVEN("A mod file with an INITIAL inside NET_RECEIVE") {
@@ -938,7 +949,7 @@
         a = 1.0;
         auto& nsb = ml->_net_send_buffer;
     })";
-            REQUIRE_THAT(generated, Contains(expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code));
         }
     }
 
@@ -955,7 +966,7 @@
             std::string expected_code(
                 "net_send_buffering(nt, ml->_net_send_buffer, 0, inst->tqitem[0*pnodecount+id], "
                 "weight_index, point_process, nt->_t+5.0, 1.0);");
-            REQUIRE_THAT(generated, Contains(expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code));
         }
     }
 
@@ -970,7 +981,7 @@
             std::string expected_code(
                 "net_send_buffering(nt, ml->_net_send_buffer, 0, inst->tqitem[0*pnodecount+id], 0, "
                 "point_process, nt->_t+5.0, 1.0);");
-            REQUIRE_THAT(generated, Contains(expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code));
         }
     }
 
@@ -1009,9 +1020,9 @@
 
         }
     })";
-            REQUIRE_THAT(generated, Contains(net_receive_kernel_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(net_receive_kernel_expected_code));
             std::string registration_expected_code = "add_nrn_fornetcons(mech_type, 0);";
-            REQUIRE_THAT(generated, Contains(registration_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(registration_expected_code));
         }
     }
     GIVEN("A mod file with a net_move outside NET_RECEIVE") {
@@ -1063,7 +1074,7 @@
             }
         };
     })";
-            REQUIRE_THAT(generated, Contains(newton_state_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(newton_state_expected_code));
             std::string state_expected_code =
                 R"(int state_(int id, int pnodecount, double* data, Datum* indexes, ThreadDatum* thread, NrnThread* nt, Memb_list* ml, double v) {
         auto* const inst = static_cast<_Instance*>(ml->instance);
@@ -1077,7 +1088,7 @@
         int reset = nrn_newton_thread(static_cast<NewtonSpace*>(*newtonspace1(thread)), 1, slist2, _newton_state_{}, dlist2, id, pnodecount, data, indexes, thread, nt, ml, v);
         return reset;
     })";
-            REQUIRE_THAT(generated, Contains(state_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(state_expected_code));
         }
     }
 }
@@ -1112,7 +1123,7 @@
             inst->Dn[id] = (2.0 + inst->m[id] - inf) * inst->n[id];
             inst->m[id] = inst->m[id] + nt->_dt * inst->Dm[id];
             inst->n[id] = inst->n[id] + nt->_dt * inst->Dn[id];)";
-            REQUIRE_THAT(generated, Contains(nrn_state_expected_code));
+            REQUIRE_THAT(generated, ContainsSubstring(nrn_state_expected_code));
         }
     }
 }
@@ -1154,8 +1165,8 @@
             std::string expected_code_proc = R"(#pragma omp atomic update
         inst->foo[id] = inst->foo[id] - 21.0;)";
 
-            REQUIRE_THAT(generated, Contains(expected_code_initial));
-            REQUIRE_THAT(generated, Contains(expected_code_proc));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code_initial));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_code_proc));
         }
     }
 }
--- a/test/unit/codegen/codegen_helper.cpp
+++ b/test/unit/codegen/codegen_helper.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "codegen/codegen_helper_visitor.hpp"
--- a/test/unit/codegen/codegen_utils.cpp
+++ b/test/unit/codegen/codegen_utils.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "codegen/codegen_cpp_visitor.hpp"
 #include "codegen/codegen_utils.hpp"
--- a/test/unit/codegen/main.cpp
+++ b/test/unit/codegen/main.cpp
@@ -5,9 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_RUNNER
-
-#include <catch2/catch.hpp>
+#include <catch2/catch_session.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "pybind/pyembed.hpp"
 #include "utils/logger.hpp"
--- a/test/unit/codegen/transform.cpp
+++ b/test/unit/codegen/transform.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "codegen/codegen_transform_visitor.hpp"
--- a/test/unit/crout/crout.cpp
+++ b/test/unit/crout/crout.cpp
@@ -5,11 +5,9 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include "nmodl.hpp"
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include <chrono>
 #include <iostream>
--- a/test/unit/lexer/tokens.cpp
+++ b/test/unit/lexer/tokens.cpp
@@ -5,11 +5,9 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <string>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "lexer/modtoken.hpp"
 #include "lexer/nmodl_lexer.hpp"
--- a/test/unit/modtoken/modtoken.cpp
+++ b/test/unit/modtoken/modtoken.cpp
@@ -5,12 +5,10 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <memory.h>
 #include <string>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "lexer/modtoken.hpp"
 #include "lexer/nmodl_lexer.hpp"
--- a/test/unit/newton/newton.cpp
+++ b/test/unit/newton/newton.cpp
@@ -5,11 +5,10 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include "nmodl.hpp"
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_floating_point.hpp>
 
 #include <cmath>
 
@@ -36,7 +35,7 @@
             CAPTURE(iter_newton);
             CAPTURE(X);
             REQUIRE(iter_newton > 0);
-            REQUIRE(X[0] == Approx(1.0));
+            REQUIRE_THAT(X[0], Catch::Matchers::WithinRel(1.0, 0.01));
             REQUIRE(F.norm() < max_error_norm);
         }
     }
@@ -57,7 +56,7 @@
             CAPTURE(iter_newton);
             CAPTURE(X);
             REQUIRE(iter_newton > 0);
-            REQUIRE(X[0] == Approx(2.19943987001206));
+            REQUIRE_THAT(X[0], Catch::Matchers::WithinRel(2.19943987001206, 0.01));
             REQUIRE(F.norm() < max_error_norm);
         }
     }
@@ -224,7 +223,7 @@
             CAPTURE(iter_newton);
             CAPTURE(X);
             REQUIRE(iter_newton > 0);
-            REQUIRE(X[0] == Approx(1.0));
+            REQUIRE_THAT(X[0], Catch::Matchers::WithinRel(1.0, 0.01));
             REQUIRE(F.norm() < max_error_norm);
         }
     }
@@ -248,7 +247,7 @@
             CAPTURE(iter_newton);
             CAPTURE(X);
             REQUIRE(iter_newton > 0);
-            REQUIRE(X[0] == Approx(2.19943987001206));
+            REQUIRE_THAT(X[0], Catch::Matchers::WithinRel(2.19943987001206, 0.01));
             REQUIRE(F.norm() < max_error_norm);
         }
     }
--- a/test/unit/parser/parser.cpp
+++ b/test/unit/parser/parser.cpp
@@ -5,12 +5,11 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <string>
 #include <utility>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "lexer/modtoken.hpp"
@@ -34,8 +33,8 @@
 }
 
 
-SCENARIO("NMODL can accept \\r as return char for one line comment", "[parser]") {
-    GIVEN("A comment defined with \\r as return char") {
+SCENARIO("NMODL can accept CR as return char for one line comment", "[parser]") {
+    GIVEN("A comment defined with CR as return char") {
         WHEN("parsing") {
             THEN("success") {
                 REQUIRE(is_valid_construct(R"(: see you next line
@@ -64,7 +63,7 @@
         WHEN("DEFINE SIX 6 DEFINE NSTEP SIX") {
             THEN("parser throws an error") {
                 REQUIRE_THROWS_WITH(is_valid_construct("DEFINE SIX 6 DEFINE NSTEP SIX"),
-                                    Catch::Contains("unexpected INVALID_TOKEN"));
+                                    Catch::Matchers::ContainsSubstring("unexpected INVALID_TOKEN"));
             }
         }
     }
@@ -73,7 +72,7 @@
         WHEN("DEFINE NSTEP 6.0") {
             THEN("parser throws an exception") {
                 REQUIRE_THROWS_WITH(is_valid_construct("DEFINE NSTEP 6.0"),
-                                    Catch::Contains("unexpected REAL"));
+                                    Catch::Matchers::ContainsSubstring("unexpected REAL"));
             }
         }
     }
@@ -82,7 +81,7 @@
         WHEN("DEFINE NSTEP") {
             THEN("parser throws an exception") {
                 REQUIRE_THROWS_WITH(is_valid_construct("DEFINE NSTEP"),
-                                    Catch::Contains("expecting INTEGER"));
+                                    Catch::Matchers::ContainsSubstring("expecting INTEGER"));
             }
         }
     }
@@ -91,7 +90,7 @@
         WHEN("DEFINE NSTEP SIX") {
             THEN("parser throws an exception") {
                 REQUIRE_THROWS_WITH(is_valid_construct("DEFINE NSTEP SIX"),
-                                    Catch::Contains("expecting INTEGER"));
+                                    Catch::Matchers::ContainsSubstring("expecting INTEGER"));
             }
         }
     }
@@ -100,7 +99,7 @@
         WHEN("DEFINE 6") {
             THEN("parser throws an exception") {
                 REQUIRE_THROWS_WITH(is_valid_construct("DEFINE 6"),
-                                    Catch::Contains("expecting NAME"));
+                                    Catch::Matchers::ContainsSubstring("expecting NAME"));
             }
         }
     }
@@ -162,18 +161,20 @@
 
 SCENARIO("Check that the parser doesn't crash when passing invalid INCLUDE constructs") {
     GIVEN("An empty filename") {
-        REQUIRE_THROWS_WITH(is_valid_construct("INCLUDE \"\""), Catch::Contains("empty filename"));
+        REQUIRE_THROWS_WITH(is_valid_construct("INCLUDE \"\""),
+                            Catch::Matchers::ContainsSubstring("empty filename"));
     }
 
     GIVEN("An missing included file") {
         REQUIRE_THROWS_WITH(is_valid_construct("INCLUDE \"unknown.file\""),
-                            Catch::Contains("can not open file : \"unknown.file\""));
+                            Catch::Matchers::ContainsSubstring(
+                                "can not open file : \"unknown.file\""));
     }
 
     GIVEN("An invalid included file") {
         TempFile included("included.file", nmodl_invalid_constructs.at("title_1").input);
         REQUIRE_THROWS_WITH(is_valid_construct("INCLUDE \"included.file\""),
-                            Catch::Contains("unexpected End of file"));
+                            Catch::Matchers::ContainsSubstring("unexpected End of file"));
     }
 }
 
@@ -188,9 +189,9 @@
     GIVEN("Incomplete CURIE information statement") {
         THEN("parser throws an error") {
             REQUIRE_THROWS_WITH(is_valid_construct("NEURON { REPRESENTS }"),
-                                Catch::Contains("Lexer Error"));
+                                Catch::Matchers::ContainsSubstring("Lexer Error"));
             REQUIRE_THROWS_WITH(is_valid_construct("NEURON { REPRESENTS NCIT}"),
-                                Catch::Contains("Lexer Error"));
+                                Catch::Matchers::ContainsSubstring("Lexer Error"));
         }
     }
 }
--- a/test/unit/printer/printer.cpp
+++ b/test/unit/printer/printer.cpp
@@ -5,11 +5,10 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
+#include <sstream>
 #include <string>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "printer/json_printer.hpp"
 
--- a/test/unit/symtab/symbol_table.cpp
+++ b/test/unit/symtab/symbol_table.cpp
@@ -5,12 +5,11 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <memory>
 #include <string>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/float.hpp"
 #include "ast/program.hpp"
@@ -63,9 +62,9 @@
             NmodlType result = prop1 | prop2 | prop3;
             result |= NmodlType::write_ion_var;
             THEN("to_string returns all added properties") {
-                REQUIRE_THAT(to_string(result), Catch::Contains("local"));
-                REQUIRE_THAT(to_string(result), Catch::Contains("global"));
-                REQUIRE_THAT(to_string(result), Catch::Contains("write_ion"));
+                REQUIRE_THAT(to_string(result), Catch::Matchers::ContainsSubstring("local"));
+                REQUIRE_THAT(to_string(result), Catch::Matchers::ContainsSubstring("global"));
+                REQUIRE_THAT(to_string(result), Catch::Matchers::ContainsSubstring("write_ion"));
             }
             WHEN("checked for property") {
                 THEN("has all added properties") {
@@ -173,9 +172,10 @@
         WHEN("checked methods and member variables") {
             THEN("all members are initialized") {
                 REQUIRE(table->under_global_scope());
-                REQUIRE_THAT(table->name(), Catch::Contains("Na"));
-                REQUIRE_THAT(table->get_parent_table_name(), Catch::Contains("None"));
-                REQUIRE_THAT(table->position(), Catch::Contains("UNKNOWN"));
+                REQUIRE_THAT(table->name(), Catch::Matchers::ContainsSubstring("Na"));
+                REQUIRE_THAT(table->get_parent_table_name(),
+                             Catch::Matchers::ContainsSubstring("None"));
+                REQUIRE_THAT(table->position(), Catch::Matchers::ContainsSubstring("UNKNOWN"));
             }
         }
         WHEN("insert symbol") {
@@ -189,7 +189,8 @@
             }
             WHEN("re-inserting the same symbol") {
                 THEN("throws an exception") {
-                    REQUIRE_THROWS_WITH(table->insert(symbol), Catch::Contains("re-insert"));
+                    REQUIRE_THROWS_WITH(table->insert(symbol),
+                                        Catch::Matchers::ContainsSubstring("re-insert"));
                 }
             }
             WHEN("inserting another symbol") {
@@ -295,19 +296,21 @@
 
         WHEN("trying to exit scope without entering") {
             THEN("throws an exception") {
-                REQUIRE_THROWS_WITH(mod_symtab.leave_scope(), Catch::Contains("without entering"));
+                REQUIRE_THROWS_WITH(mod_symtab.leave_scope(),
+                                    Catch::Matchers::ContainsSubstring("without entering"));
             }
         }
         WHEN("trying to enter scope without valid node") {
             THEN("throws an exception") {
                 REQUIRE_THROWS_WITH(mod_symtab.enter_scope("scope", nullptr, true, old_symtab),
-                                    Catch::Contains("empty node"));
+                                    Catch::Matchers::ContainsSubstring("empty node"));
             }
         }
         WHEN("trying to insert without entering scope") {
             THEN("throws an exception") {
                 auto symbol = std::make_shared<Symbol>("alpha");
-                REQUIRE_THROWS_WITH(mod_symtab.insert(symbol), Catch::Contains("Can not insert"));
+                REQUIRE_THROWS_WITH(mod_symtab.insert(symbol),
+                                    Catch::Matchers::ContainsSubstring("Can not insert"));
             }
         }
         WHEN("enter scope multipel times") {
@@ -335,7 +338,8 @@
             mod_symtab.insert(symbol1);
             mod_symtab.insert(symbol2);
             THEN("throws an exception") {
-                REQUIRE_THROWS_WITH(mod_symtab.insert(symbol3), Catch::Contains("Re-declaration"));
+                REQUIRE_THROWS_WITH(mod_symtab.insert(symbol3),
+                                    Catch::Matchers::ContainsSubstring("Re-declaration"));
             }
         }
         WHEN("added same symbol in children scope") {
--- a/test/unit/units/lexer.cpp
+++ b/test/unit/units/lexer.cpp
@@ -5,11 +5,9 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <string>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "lexer/unit_lexer.hpp"
 #include "parser/unit_driver.hpp"
--- a/test/unit/units/parser.cpp
+++ b/test/unit/units/parser.cpp
@@ -5,12 +5,11 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_MAIN
-
 #include <string>
 #include <utility>
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "config/config.h"
 #include "parser/diffeq_driver.hpp"
@@ -22,7 +21,7 @@
 //=============================================================================
 
 using namespace nmodl::test_utils;
-using Catch::Matchers::Contains;
+using Catch::Matchers::ContainsSubstring;
 
 // Driver is defined as global to store all the units inserted to it and to be
 // able to define complex units based on base units
@@ -154,7 +153,7 @@
             THEN("parser multiply the number by the factor") {
                 std::string parsed_unit{};
                 REQUIRE_NOTHROW(parsed_unit = parse_string("pew 1 1/milli"));
-                REQUIRE_THAT(parsed_unit, Contains("pew 0.001: 0 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_unit, ContainsSubstring("pew 0.001: 0 0 0 0 0 0 0 0 0 0"));
             }
         }
     }
@@ -192,20 +191,24 @@
                 R2      8314 mV-coul/degC
                 )";
                 std::string parsed_units = parse_string(reindent_text(units_definitions));
-                REQUIRE_THAT(parsed_units, Contains("mV 0.001: 2 1 -2 -1 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("mM 1: -3 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("mA 0.001: 0 0 -1 1 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("KTOMV 8.53e-05: 2 1 -2 -1 0 0 0 0 0 -1"));
-                REQUIRE_THAT(parsed_units, Contains("B 26: -1 0 0 -1 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("dummy1 0.025: -2 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("dummy2 0.025: -2 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("dummy3 0.025: -2 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("dummy4 -0.025: -2 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("dummy5 0.025: 0 0 0 0 0 0 0 0 0 0"));
-                REQUIRE_THAT(parsed_units, Contains("newR 8.31446: 2 1 -2 0 0 0 0 0 0 -1"));
-                REQUIRE_THAT(parsed_units, Contains("R1 8.314: 2 1 -2 0 0 0 0 0 0 -1"));
-                REQUIRE_THAT(parsed_units, Contains("R2 8.314: 2 1 -2 0 0 0 0 0 0 -1"));
-                REQUIRE_THAT(parsed_units, Contains("m kg sec coul candela dollar bit erlang K"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("mV 0.001: 2 1 -2 -1 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("mM 1: -3 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("mA 0.001: 0 0 -1 1 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units,
+                             ContainsSubstring("KTOMV 8.53e-05: 2 1 -2 -1 0 0 0 0 0 -1"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("B 26: -1 0 0 -1 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("dummy1 0.025: -2 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("dummy2 0.025: -2 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("dummy3 0.025: -2 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units,
+                             ContainsSubstring("dummy4 -0.025: -2 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("dummy5 0.025: 0 0 0 0 0 0 0 0 0 0"));
+                REQUIRE_THAT(parsed_units,
+                             ContainsSubstring("newR 8.31446: 2 1 -2 0 0 0 0 0 0 -1"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("R1 8.314: 2 1 -2 0 0 0 0 0 0 -1"));
+                REQUIRE_THAT(parsed_units, ContainsSubstring("R2 8.314: 2 1 -2 0 0 0 0 0 0 -1"));
+                REQUIRE_THAT(parsed_units,
+                             ContainsSubstring("m kg sec coul candela dollar bit erlang K"));
             }
         }
     }
--- a/test/unit/visitor/after_cvode_to_cnexp.cpp
+++ b/test/unit/visitor/after_cvode_to_cnexp.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/constant_folder.cpp
+++ b/test/unit/visitor/constant_folder.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/defuse_analyze.cpp
+++ b/test/unit/visitor/defuse_analyze.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_session.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/binary_expression.hpp"
 #include "ast/program.hpp"
--- a/test/unit/visitor/global_to_range.cpp
+++ b/test/unit/visitor/global_to_range.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/implicit_argument.cpp
+++ b/test/unit/visitor/implicit_argument.cpp
@@ -11,12 +11,13 @@
 #include "visitors/symtab_visitor.hpp"
 #include "visitors/visitor_utils.hpp"
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 using namespace nmodl;
 using nmodl::test_utils::reindent_text;
 
-using Catch::Matchers::Contains;  // ContainsSubstring in newer Catch2
+using Catch::Matchers::ContainsSubstring;  // ContainsSubstring in newer Catch2
 
 //=============================================================================
 // Implicit visitor tests
@@ -46,15 +47,15 @@
         )";
         auto const modified_nmodl = generate_mod_after_implicit_argument_visitor(nmodl_text);
         THEN("at_time should have nt as its first argument") {
-            REQUIRE_THAT(modified_nmodl, Contains("at_time(nt, foo)"));
-            REQUIRE_THAT(modified_nmodl, Contains("at_time(nt, a+b)"));
-            REQUIRE_THAT(modified_nmodl, Contains("at_time(nt, flop)"));
+            REQUIRE_THAT(modified_nmodl, ContainsSubstring("at_time(nt, foo)"));
+            REQUIRE_THAT(modified_nmodl, ContainsSubstring("at_time(nt, a+b)"));
+            REQUIRE_THAT(modified_nmodl, ContainsSubstring("at_time(nt, flop)"));
         }
         THEN("nrn_ghk should have a temperature as its last argument") {
             REQUIRE_THAT(modified_nmodl,
-                         Contains("nrn_ghk(-50(mV), .001(mM), 10(mM), 2, celsius)"));
+                         ContainsSubstring("nrn_ghk(-50(mV), .001(mM), 10(mM), 2, celsius)"));
             REQUIRE_THAT(modified_nmodl,
-                         Contains("nrn_ghk(-50(mV), .001(mM), 10(mM), 2, -273.15)"));
+                         ContainsSubstring("nrn_ghk(-50(mV), .001(mM), 10(mM), 2, -273.15)"));
         }
     }
 }
--- a/test/unit/visitor/inline.cpp
+++ b/test/unit/visitor/inline.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/json.cpp
+++ b/test/unit/visitor/json.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/kinetic_block.cpp
+++ b/test/unit/visitor/kinetic_block.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/local_to_assigned.cpp
+++ b/test/unit/visitor/local_to_assigned.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/localize.cpp
+++ b/test/unit/visitor/localize.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/lookup.cpp
+++ b/test/unit/visitor/lookup.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/loop_unroll.cpp
+++ b/test/unit/visitor/loop_unroll.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/main.cpp
+++ b/test/unit/visitor/main.cpp
@@ -5,9 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#define CATCH_CONFIG_RUNNER
-
-#include <catch2/catch.hpp>
+#include <catch2/catch_session.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "pybind/pyembed.hpp"
 #include "utils/logger.hpp"
--- a/test/unit/visitor/misc.cpp
+++ b/test/unit/visitor/misc.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/neuron_solve.cpp
+++ b/test/unit/visitor/neuron_solve.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/nmodl.cpp
+++ b/test/unit/visitor/nmodl.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/node_index.cpp
+++ b/test/unit/visitor/node_index.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/perf.cpp
+++ b/test/unit/visitor/perf.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
@@ -152,7 +153,8 @@
         WHEN("Perf visitor pass runs before symtab visitor") {
             PerfVisitor v;
             THEN("exception is thrown") {
-                REQUIRE_THROWS_WITH(v.visit_program(*ast), Catch::Contains("table not setup"));
+                REQUIRE_THROWS_WITH(v.visit_program(*ast),
+                                    Catch::Matchers::ContainsSubstring("table not setup"));
             }
         }
     }
--- a/test/unit/visitor/rename.cpp
+++ b/test/unit/visitor/rename.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/semantic_analysis.cpp
+++ b/test/unit/visitor/semantic_analysis.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/solve_block.cpp
+++ b/test/unit/visitor/solve_block.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/steadystate.cpp
+++ b/test/unit/visitor/steadystate.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/sympy_conductance.cpp
+++ b/test/unit/visitor/sympy_conductance.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/sympy_solver.cpp
+++ b/test/unit/visitor/sympy_solver.cpp
@@ -5,7 +5,8 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/matchers/catch_matchers_string.hpp>
 
 #include "ast/program.hpp"
 #include "codegen/codegen_cpp_visitor.hpp"
@@ -29,7 +30,7 @@
 using namespace test;
 using namespace test_utils;
 
-using Catch::Matchers::Contains;  // ContainsSubstring in newer Catch2
+using Catch::Matchers::ContainsSubstring;  // ContainsSubstring in newer Catch2
 
 using nmodl::test_utils::reindent_text;
 
@@ -818,8 +819,9 @@
             "equations") {
             REQUIRE_THROWS_WITH(
                 run_sympy_solver_visitor(nmodl_text, false, false, AstNodeType::DERIVATIVE_BLOCK),
-                Catch::Matchers::Contains("State variable assignment(s) interleaved in system of "
-                                          "equations/differential equations") &&
+                Catch::Matchers::ContainsSubstring(
+                    "State variable assignment(s) interleaved in system of "
+                    "equations/differential equations") &&
                     Catch::Matchers::StartsWith("SympyReplaceSolutionsVisitor"));
         }
     }
@@ -2412,12 +2414,12 @@
             std::string expected_functor_cacum_2_usage =
                 R"(functor_cacum_2 newton_functor(nt, inst, id, pnodecount, v, indexes, data, thread);)";
 
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_0_definition));
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_1_definition));
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_2_definition));
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_0_usage));
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_1_usage));
-            REQUIRE_THAT(generated, Contains(expected_functor_cacum_2_usage));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_0_definition));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_1_definition));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_2_definition));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_0_usage));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_1_usage));
+            REQUIRE_THAT(generated, ContainsSubstring(expected_functor_cacum_2_usage));
         }
     }
 }
--- a/test/unit/visitor/units.cpp
+++ b/test/unit/visitor/units.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 #include <fmt/format.h>
 
 #include "ast/double.hpp"
--- a/test/unit/visitor/var_usage.cpp
+++ b/test/unit/visitor/var_usage.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/visitor/verbatim.cpp
+++ b/test/unit/visitor/verbatim.cpp
@@ -5,7 +5,7 @@
  * Lesser General Public License. See top-level LICENSE file for details.
  *************************************************************************/
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 #include "ast/program.hpp"
 #include "parser/nmodl_driver.hpp"
--- a/test/unit/fast_math/fast_math.cpp
+++ b/test/unit/fast_math/fast_math.cpp
@@ -9,7 +9,7 @@
 
 #include "codegen/fast_math.hpp"
 
-#include <catch2/catch.hpp>
+#include <catch2/catch_test_macros.hpp>
 
 namespace nmodl {
 namespace fast_math {