| 1083 | #include "gtest/gtest.h" |
| 1084 | |
| 1085 | TEST(actions, MatchingRegexp) { |
| 1086 | AllocVariableTable vt(nullptr); |
| 1087 | int id = vt.find("1", true); |
| 1088 | int sub1_id = vt.find("2", true); |
| 1089 | int sub2_id = vt.find("3", true); |
| 1090 | int sub3_id = vt.find("4", true); |
| 1091 | int sub4_id = vt.find("5", true); |
| 1092 | CAction re(nullptr); |
| 1093 | re.setVarId(id); |
| 1094 | re.setNbSubVarId(4); |
| 1095 | re.setSubVarId(sub1_id); |
| 1096 | re.setSubVarId(sub2_id); |
| 1097 | re.setSubVarId(sub3_id); |
| 1098 | re.setSubVarId(sub4_id); |
| 1099 | re.setRegExp("(.+)(o) (.+)(d)"); |
| 1100 | int results = re.executeRegExp("hello world", &vt); |
| 1101 | |
| 1102 | ASSERT_EQ(5, results); |
| 1103 | ASSERT_STREQ("hello world", vt.getVar(id)->getString()); |
| 1104 | ASSERT_STREQ("hell", vt.getVar(sub1_id)->getString()); |
| 1105 | ASSERT_STREQ("o", vt.getVar(sub2_id)->getString()); |
| 1106 | ASSERT_STREQ("worl", vt.getVar(sub3_id)->getString()); |
| 1107 | ASSERT_STREQ("d", vt.getVar(sub4_id)->getString()); |
| 1108 | } |
| 1109 | |
| 1110 | TEST(actions, NonMatchingRegexp) { |
| 1111 | AllocVariableTable vt(nullptr); |
nothing calls this directly
no test coverage detected