| 21 | }; |
| 22 | |
| 23 | TEST_F(TestTypeAnalyzer, getReportP) { |
| 24 | std::string Code = "enum E1 { M1, M2, M3 };\n" |
| 25 | "namespace N1 { enum E2 { M1 = 3, M2, M3 }; }\n" |
| 26 | "namespace { enum E3 { M1 = 6, M2, M3 }; }\n"; |
| 27 | SourceFileManager SFM; |
| 28 | SFM.createFile("test.cpp", Code); |
| 29 | ASSERT_TRUE(load(SFM.getSrcDirPath(), SFM.getFilePath("test.cpp"))); |
| 30 | |
| 31 | TypeAnalyzer Analyzer(SC->getASTUnits()); |
| 32 | auto Report = Analyzer.getReport(); |
| 33 | ASSERT_TRUE(Report); |
| 34 | |
| 35 | Json::Value AnswerJson = util::strToJson(R"( |
| 36 | { |
| 37 | "typeanalysis": { |
| 38 | "enums": { |
| 39 | "(anonymous namespace)::E3": { |
| 40 | "Enumerators": [ |
| 41 | {"Name": "M1","Value": 6}, |
| 42 | {"Name": "M2","Value": 7}, |
| 43 | {"Name": "M3","Value": 8} |
| 44 | ], |
| 45 | "Name": "(anonymous namespace)::E3" |
| 46 | }, |
| 47 | "E1": { |
| 48 | "Enumerators": [ |
| 49 | { "Name": "M1", "Value": 0 }, |
| 50 | { "Name": "M2", "Value": 1 }, |
| 51 | { "Name": "M3", "Value": 2 } |
| 52 | ], |
| 53 | "Name": "E1" |
| 54 | }, |
| 55 | "N1::E2": { |
| 56 | "Enumerators": [ |
| 57 | { "Name": "M1", "Value": 3 }, |
| 58 | { "Name": "M2", "Value": 4 }, |
| 59 | { "Name": "M3", "Value": 5 } |
| 60 | ], |
| 61 | "Name": "N1::E2" |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | )"); |
| 67 | ASSERT_EQ(Report->toJson(), AnswerJson); |
| 68 | } |
| 69 | |
| 70 | TEST_F(TestTypeAnalyzer, getReportN) { |
| 71 | std::string Code = ""; |
nothing calls this directly
no test coverage detected