| 44 | } |
| 45 | |
| 46 | TEST(ValidateCppIdent, Simple) { |
| 47 | TF_EXPECT_OK(ValidateCppIdent("a", "")); |
| 48 | TF_EXPECT_OK(ValidateCppIdent("abc", "")); |
| 49 | TF_EXPECT_OK(ValidateCppIdent("_abc", "")); |
| 50 | TF_EXPECT_OK(ValidateCppIdent("_abc123", "")); |
| 51 | // Make sure we didn't skip a valid letter or digit |
| 52 | string ident; |
| 53 | for (char c = 'a'; c <= 'z'; c++) { |
| 54 | ident.append(1, c); |
| 55 | } |
| 56 | for (char c = 'A'; c <= 'Z'; c++) { |
| 57 | ident.append(1, c); |
| 58 | } |
| 59 | for (char c = '0'; c <= '9'; c++) { |
| 60 | ident.append(1, c); |
| 61 | } |
| 62 | ident += "_"; |
| 63 | TF_EXPECT_OK(ValidateCppIdent(ident, "")); |
| 64 | |
| 65 | ExpectErrorContains(ValidateCppIdent("", ""), "empty identifier"); |
| 66 | ExpectErrorContains(ValidateCppIdent(" ", ""), "illegal leading char"); |
| 67 | ExpectErrorContains(ValidateCppIdent("0", ""), "illegal leading char"); |
| 68 | ExpectErrorContains(ValidateCppIdent(".", ""), "illegal leading char"); |
| 69 | ExpectErrorContains(ValidateCppIdent(":", ""), "illegal leading char"); |
| 70 | ExpectErrorContains(ValidateCppIdent("a.", ""), "illegal char"); |
| 71 | ExpectErrorContains(ValidateCppIdent("a:", ""), "illegal char"); |
| 72 | ExpectErrorContains(ValidateCppIdent("a:", ""), "illegal char"); |
| 73 | } |
| 74 | |
| 75 | class ParseCppClassTest : public ::testing::Test { |
| 76 | protected: |
nothing calls this directly
no test coverage detected