check rangeString: 1> rangeString is valid and every char is '0'-'9' or '-' 2> char '-' count <= 2; return: false if 1> or 2> fail;
| 27 | // return: |
| 28 | // false if 1> or 2> fail; |
| 29 | bool checkScreenShotFrameRangeString(const char *rangeString) { |
| 30 | bool checkResult = false; |
| 31 | char *currentChar = const_cast<char *>(rangeString); |
| 32 | int dashCount = 0; |
| 33 | |
| 34 | if (rangeString != nullptr) { |
| 35 | checkResult = true; |
| 36 | while (*currentChar != '\0') { |
| 37 | if ((*currentChar >= '0') && (*currentChar <= '9')) { |
| 38 | currentChar++; |
| 39 | } else if (*currentChar == '-') { |
| 40 | dashCount++; |
| 41 | currentChar++; |
| 42 | } else { |
| 43 | checkResult = false; |
| 44 | break; |
| 45 | } |
| 46 | } |
| 47 | checkResult = checkResult && (dashCount <= 2); |
| 48 | } |
| 49 | return checkResult; |
| 50 | } |
| 51 | |
| 52 | // initialize pFrameRange, parse rangeString and set value to members of *pFrameRange. |
| 53 | // the string of rangeString can be and must be one of the following values: |
no outgoing calls
no test coverage detected