Skip to content

Commit

Permalink
#5799: Add unit test covering IDeclarationManager::saveDeclaration no…
Browse files Browse the repository at this point in the history
…t being able to find the declaration with a commment after the opening brace.
  • Loading branch information
codereader committed Jul 17, 2022
1 parent 43c8420 commit 7cab1de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/DeclManager.cpp
Expand Up @@ -1016,6 +1016,26 @@ TEST_F(DeclManagerTest, SaveExistingDeclWithMixedCaseTypename)
// The test fixture will restore the original file contents in TearDown
}

// Looks like this: testdecl decl/numbers/5 { // a comment in the same line as the opening brace
TEST_F(DeclManagerTest, SaveExistingDeclWithCommentInTheSameLine)
{
GlobalDeclarationManager().registerDeclType("testdecl", std::make_shared<TestDeclarationCreator>());
GlobalDeclarationManager().registerDeclFolder(decl::Type::TestDecl, TEST_DECL_FOLDER, ".decl");

auto decl = std::static_pointer_cast<ITestDeclaration>(
GlobalDeclarationManager().findDeclaration(decl::Type::TestDecl, "decl/numbers/5"));

// Swap some contents of this decl
decl->setKeyValue("diffusemap", "textures/changed/5");

// Save, then it should be present in the file
GlobalDeclarationManager().saveDeclaration(decl);

expectDeclIsPresentInFile(decl, decl->getBlockSyntax().fileInfo.fullPath(), true);

// The test fixture will restore the original file contents in TearDown
}

TEST_F(DeclManagerTest, SetDeclFileInfo)
{
GlobalDeclarationManager().registerDeclType("testdecl", std::make_shared<TestDeclarationCreator>());
Expand Down
4 changes: 4 additions & 0 deletions test/resources/tdm/testdecls/numbers.decl
Expand Up @@ -22,3 +22,7 @@ TestDecl decl/numbers/3
}

testdecl2 decltable1 { { 0, 0, 0, 0, 1, 1 } }

testdecl decl/numbers/5 { // a comment in the same line as the opening brace
diffusemap textures/numbers/5
}

0 comments on commit 7cab1de

Please sign in to comment.