Skip to content

Commit f529eec

Browse files
Add automated tests
1 parent af241f8 commit f529eec

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/automated-tests.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "cppmenu.h"
2+
#include <iostream>
3+
#include <exception>
4+
5+
void foo() {
6+
return;
7+
}
8+
9+
int main()
10+
{
11+
try
12+
{
13+
CppMenu::CommonMenu menu
14+
{
15+
"SAMPLE TITLE",
16+
17+
{
18+
{ "Function Title", &foo, false }
19+
},
20+
21+
true
22+
};
23+
24+
if (false)
25+
menu.run(); //not executing so that the building and testing log doesn't get erased in case of running ctest -V
26+
27+
std::cout << "Automated tests passed.\n"
28+
<< "You can include the cppmenu.h header file and use the CppMenu namespace.\n"
29+
<< "You can try to run CppMenu-Tests executable to test the library's menus.\n";
30+
}
31+
catch (const std::exception& exception)
32+
{
33+
std::cerr << "CppMenu library's automated tests failed\n"
34+
<< "Error: " << exception.what() << '\n';
35+
36+
return 1;
37+
}
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)