MCPcopy Create free account
hub / github.com/crownengine/crown / test_command_line

Function test_command_line

src/core/unit_tests.cpp:1820–1848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1818}
1819
1820static void test_command_line()
1821{
1822 {
1823 const char *argv[] = { "prog", "-s", "--switch" };
1824 CommandLine cl(countof(argv), argv);
1825
1826 ENSURE(cl.has_option("switch", 's'));
1827 }
1828 {
1829 const char *argv[] = { "prog", "--args", "orange", "apple" };
1830 CommandLine cl(countof(argv), argv);
1831
1832 const char *orange = cl.get_parameter(0, "args");
1833 ENSURE(orange != NULL && strcmp(orange, "orange") == 0);
1834 const char *apple = cl.get_parameter(1, "args");
1835 ENSURE(apple != NULL && strcmp(apple, "apple") == 0);
1836 const char *banana = cl.get_parameter(2, "banana");
1837 ENSURE(banana == NULL);
1838 }
1839 {
1840 const char *argv[] = { "prog", "--bar", "--", "--baz" };
1841 CommandLine cl(countof(argv), argv);
1842
1843 ENSURE(cl.has_option("bar"));
1844 ENSURE(!cl.has_option("baz"));
1845 ENSURE(!cl.has_option("--"));
1846 ENSURE(cl.get_parameter(0, "bar") == NULL);
1847 }
1848}
1849
1850static void test_thread()
1851{

Callers

nothing calls this directly

Calls 3

strcmpFunction · 0.85
has_optionMethod · 0.80
get_parameterMethod · 0.80

Tested by

no test coverage detected