Skip to content

Commit 317addc

Browse files
authored
Merge pull request #523 from mcserep/cppparsertest-fixes
Fixes for CppParserTest
2 parents f7eef38 + a8ae216 commit 317addc

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build project
33
on: [push, pull_request, workflow_dispatch]
44

55
env:
6-
BUILD_TYPE: Release
6+
BUILD_TYPE: Debug
77

88
jobs:
99
build:

plugins/cpp/test/src/cppparsertest.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <model/cppnamespace-odb.hxx>
1414
#include <model/cpprecord.h>
1515
#include <model/cpprecord-odb.hxx>
16+
#include <model/cpptypedef.h>
17+
#include <model/cpptypedef-odb.hxx>
1618
#include <model/cppvariable.h>
1719
#include <model/cppvariable-odb.hxx>
1820
#include <model/file.h>
@@ -31,8 +33,11 @@ using QCppEnum = odb::query<model::CppEnum>;
3133
using QCppEnumConstant = odb::query<model::CppEnumConstant>;
3234
using QCppNamespace = odb::query<model::CppNamespace>;
3335
using QCppRecord = odb::query<model::CppRecord>;
36+
using QCppTypedef = odb::query<model::CppTypedef>;
3437
using QCppVariable = odb::query<model::CppVariable>;
3538
using QFile = odb::query<model::File>;
39+
using RCppEnum = odb::result<model::CppEnum>;
40+
using RCppFunction = odb::result<model::CppFunction>;
3641
using RCppAstNode = odb::result<model::CppAstNode>;
3742

3843
class CppParserTest : public ::testing::Test
@@ -135,10 +140,12 @@ TEST_F(CppParserTest, FunctionDeclarationOnly)
135140
TEST_F(CppParserTest, FunctionWithMultipleDeclarations)
136141
{
137142
_transaction([&, this]() {
138-
model::CppFunction callee = _db->query_value<model::CppFunction>(
143+
RCppFunction callees = _db->query<model::CppFunction>(
139144
QCppFunction::name == "multiFunction");
145+
EXPECT_FALSE(callees.empty());
146+
140147
RCppAstNode multiFuncAstNode = _db->query<model::CppAstNode>(
141-
QCppAstNode::entityHash == callee.entityHash);
148+
QCppAstNode::entityHash == callees.begin()->entityHash);
142149

143150
int numDecl = 0, numDef = 0, numOther = 0;
144151
for (const model::CppAstNode& n : multiFuncAstNode)
@@ -296,10 +303,11 @@ TEST_F(CppParserTest, FunctionCall)
296303
TEST_F(CppParserTest, Typedef)
297304
{
298305
_transaction([&, this]() {
299-
model::CppEnum integer = _db->query_value<model::CppEnum>(
300-
QCppEnum::name == "Integer");
306+
model::CppTypedef integer = _db->query_value<model::CppTypedef>(
307+
QCppTypedef::name == "Integer");
301308
RCppAstNode astNodes = _db->query<model::CppAstNode>(
302309
QCppAstNode::entityHash == integer.entityHash);
310+
EXPECT_FALSE(astNodes.empty());
303311

304312
for (const model::CppAstNode& n : astNodes)
305313
{
@@ -449,11 +457,15 @@ TEST_F(CppParserTest, Record)
449457

450458
TEST_F(CppParserTest, Enum)
451459
{
452-
_transaction([&, this] {
453-
model::CppEnum enumeration = _db->query_value<model::CppEnum>(
460+
_transaction([&, this]
461+
{
462+
RCppEnum enumerations = _db->query<model::CppEnum>(
454463
QCppEnum::name == "Enumeration");
464+
EXPECT_FALSE(enumerations.empty());
465+
455466
RCppAstNode astNodes = _db->query<model::CppAstNode>(
456-
QCppAstNode::entityHash == enumeration.entityHash);
467+
QCppAstNode::entityHash == enumerations.begin()->entityHash);
468+
EXPECT_FALSE(astNodes.empty());
457469

458470
for (const model::CppAstNode& n : astNodes)
459471
{
@@ -526,10 +538,15 @@ TEST_F(CppParserTest, Enum)
526538
break;
527539
}
528540
}
541+
});
542+
}
529543

530-
model::CppFunction fieldFunction = _db->query_value<model::CppFunction>(
544+
TEST_F(CppParserTest, Fields)
545+
{
546+
_transaction([&, this] {
547+
model::CppVariable fieldFunction = _db->query_value<model::CppVariable>(
531548
QCppFunction::name == "fieldFunction");
532-
astNodes = _db->query<model::CppAstNode>(
549+
RCppAstNode astNodes = _db->query<model::CppAstNode>(
533550
QCppAstNode::entityHash == fieldFunction.entityHash);
534551

535552
for (const model::CppAstNode& n : astNodes)

0 commit comments

Comments
 (0)