@@ -108,12 +108,21 @@ int main()
108108}
109109)" ;
110110
111- constexpr const char *kBasicTestCpp_App = R"( #include <iostream>
111+ constexpr const char *kBasicTestCpp_App = R"( #include <vix/tests/TestRegistry.hpp>
112+ #include <vix/tests.hpp>
112113
113114int main()
114115{
115- std::cout << "basic test OK\n";
116- return 0;
116+ using namespace vix::tests;
117+
118+ auto ®istry = TestRegistry::instance();
119+ registry.clear();
120+
121+ registry.add(TestCase("app basic test", [] {
122+ Assert::equal(2 + 2, 4);
123+ }));
124+
125+ return TestRunner::run_all_and_exit();
117126}
118127)" ;
119128
@@ -179,15 +188,26 @@ int main()
179188 static std::string make_basic_test_cpp_lib (const std::string &name)
180189 {
181190 std::string s;
182- s.reserve (800 );
191+ s.reserve (1200 );
192+
193+ s += " #include <vix/tests/TestRegistry.hpp>\n " ;
194+ s += " #include <vix/tests/TestRunner.hpp>\n " ;
195+ s += " #include <vix/tests/TestCase.hpp>\n " ;
196+ s += " #include <vix/tests/Assert.hpp>\n " ;
197+ s += " #include <" + name + " /" + name + " .hpp>\n\n " ;
183198
184- s += " #include <" + name + " /" + name + " .hpp>\n " ;
185- s += " #include <iostream>\n\n " ;
186199 s += " int main()\n " ;
187200 s += " {\n " ;
188- s += " auto nodes = " + name + " ::make_chain(5);\n " ;
189- s += " std::cout << \" nodes=\" << nodes.size() << \"\\ n\" ;\n " ;
190- s += " return nodes.size() == 5 ? 0 : 1;\n " ;
201+ s += " using namespace vix::tests;\n\n " ;
202+ s += " auto ®istry = TestRegistry::instance();\n " ;
203+ s += " registry.clear();\n\n " ;
204+
205+ s += " registry.add(TestCase(\" " + name + " basic test\" , [] {\n " ;
206+ s += " auto nodes = " + name + " ::make_chain(5);\n " ;
207+ s += " Assert::equal(nodes.size(), static_cast<std::size_t>(5));\n " ;
208+ s += " }));\n\n " ;
209+
210+ s += " return TestRunner::run_all_and_exit();\n " ;
191211 s += " }\n " ;
192212
193213 return s;
@@ -803,23 +823,6 @@ int main()
803823 std::vector<bool > selected{};
804824 };
805825
806- static bool all_checked (const std::vector<bool > &v)
807- {
808- if (v.empty ())
809- return false ;
810- for (bool b : v)
811- if (!b)
812- return false ;
813- return true ;
814- }
815-
816- static void toggle_all (std::vector<bool > &v)
817- {
818- const bool turnOn = !all_checked (v);
819- for (std::size_t i = 0 ; i < v.size (); ++i)
820- v[i] = turnOn;
821- }
822-
823826 static void render_lines (const std::vector<std::string> &lines, bool firstDraw)
824827 {
825828 const int total = (int )lines.size ();
@@ -868,7 +871,7 @@ int main()
868871
869872 int cursorIndex = 0 ;
870873 int selectedIndex = 0 ;
871- res.selected [selectedIndex] = true ;
874+ res.selected [static_cast <std:: size_t >( selectedIndex) ] = true ;
872875
873876 auto render_item = [&](const Item &item, bool active) -> std::string
874877 {
@@ -902,15 +905,15 @@ int main()
902905 out.push_back (std::string (PAD ) + BOLD + CYAN + " Core" + RESET );
903906
904907 for (int i = 0 ; i < 3 ; ++i)
905- out.push_back (render_item (items[i ], i == activeIdx));
908+ out.push_back (render_item (items[static_cast <std:: size_t >(i) ], i == activeIdx));
906909
907910 out.push_back (" " );
908911
909912 out.push_back (std::string (PAD ) + BOLD + CYAN + " Advanced" + RESET );
910913 out.push_back (render_item (items[3 ], activeIdx == 3 ));
911914
912915 out.push_back (" " );
913- out.push_back (std::string (PAD ) + ui::dim (items[activeIdx].tip ));
916+ out.push_back (std::string (PAD ) + ui::dim (items[static_cast <std:: size_t >( activeIdx) ].tip ));
914917
915918 return out;
916919 };
@@ -968,7 +971,7 @@ int main()
968971 selectedIndex = cursorIndex;
969972
970973 std::fill (res.selected .begin (), res.selected .end (), false );
971- res.selected [selectedIndex] = true ;
974+ res.selected [static_cast <std:: size_t >( selectedIndex) ] = true ;
972975
973976 if (k == Key::Enter)
974977 {
@@ -1437,7 +1440,7 @@ int main()
14371440 s += " }\n " ;
14381441 s += " },\n " ;
14391442 s += " \" test\" : {\n " ;
1440- s += " \" description\" : \" Run CTest suite \" ,\n " ;
1443+ s += " \" description\" : \" Run project tests \" ,\n " ;
14411444 s += " \" command\" : \" vix tests --preset ${preset} --fail-fast\"\n " ;
14421445 s += " },\n " ;
14431446 s += " \" dev\" : {\n " ;
0 commit comments