MCPcopy Create free account
hub / github.com/SpartanJ/eepp / UTEST

Function UTEST

src/tests/unit_tests/functionstring.cpp:9–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace EE::System;
8
9UTEST( FunctionString, functionString ) {
10 const auto testCase = [&]( const std::string& in, const std::string& funcName,
11 const std::vector<std::string>& parameters ) {
12 UTEST_PRINT_STEP( funcName.c_str() );
13 auto ret = FunctionString::parse( in );
14 EXPECT_STDSTREQ( funcName, ret.getName() );
15 for ( size_t i = 0; i < parameters.size(); i++ ) {
16 if ( i < ret.getParameters().size() )
17 EXPECT_STDSTREQ( parameters[i], ret.getParameters()[i] );
18 else
19 EXPECT_STDSTREQ( parameters[i], "" );
20 }
21 EXPECT_EQ( parameters.size(), ret.getParameters().size() );
22 };
23
24 testCase( R"(test1(12, 14))", "test1", { "12", "14" } );
25 testCase( R"(test2("string", "string2"))", "test2", { "string", "string2" } );
26 testCase( R"(test3 (16, 14, 18))", "test3", { "16", "14", "18" } );
27 testCase( R"(test4(2.0, 14))", "test4", { "2.0", "14" } );
28 testCase( R"(test5("str ing", "stri ng2"))", "test5", { "str ing", "stri ng2" } );
29 testCase( R"(test6("str\"ing", "stri\"ng2"))", "test6", { "str\"ing", "stri\"ng2" } );
30 testCase( R"(test7("str,ing", "stri,ng2"))", "test7", { "str,ing", "stri,ng2" } );
31 testCase( R"(test8("str\\ing", "stri\\ng2"))", "test8", { "str\\\\ing", "stri\\\\ng2" } );
32 testCase( R"(test9("12" , "14" ))", "test9", { "12", "14" } );
33 testCase( R"(test10(12 , 14 ))", "test10", { "12", "14" } );
34 testCase( R"(test11( "12 " , " 14 " ))", "test11", { "12 ", " 14 " } );
35 testCase( R"(test12( "12 \" " , " \" 14 \" " ))", "test12", { "12 \" ", " \" 14 \" " } );
36 testCase( R"(test13( "\"\"" , "\"\"" ))", "test13", { "\"\"", "\"\"" } );
37 testCase( R"(test14( ",,," , 1 , ",,," ))", "test14", { ",,,", "1", ",,," } );
38 testCase( R"( test15 ( ",,," , 1 , ",,," ))", "test15",
39 { ",,,", "1", ",,," } );
40 testCase( R"(test16(1,2) )", "test16", { "1", "2" } );
41 testCase( R"(test17(func(12,32),2) )", "test17", { "func(12,32)", "2" } );
42 testCase( R"(test17(func(12,32),2) )", "test17", { "func(12,32)", "2" } );
43 testCase( R"(test18( func(12,32) , 2 ) )", "test18", { "func(12,32)", "2" } );
44 testCase( R"(test19(func( "test" , "string" ), call(12,42)))", "test19",
45 { "func( \"test\" , \"string\" )", "call(12,42)" } );
46 testCase( R"(test20(var(--font), var(--back)))", "test20", { "var(--font)", "var(--back)" } );
47 testCase( R"(test21( str ing , stri ng2 ))", "test21", { "str ing", "stri ng2" } );
48 testCase( R"(test22(" 12 " , " 14 " ))", "test22",
49 { " 12 ", " 14 " } );
50 testCase( R"(test23( s t r i n g , s t r i n g 2 ))", "test23",
51 { "s t r i n g", "s t r i n g 2" } );
52 testCase( R"(test24( func( "test" , "string" ) , call(12,42) ))", "test24",
53 { "func( \"test\" , \"string\" )", "call(12,42)" } );
54}

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
getNameMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected