diff --git a/test/DeclManager.cpp b/test/DeclManager.cpp index bbdad36d0c..ab6e3b207a 100644 --- a/test/DeclManager.cpp +++ b/test/DeclManager.cpp @@ -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()); + GlobalDeclarationManager().registerDeclFolder(decl::Type::TestDecl, TEST_DECL_FOLDER, ".decl"); + + auto decl = std::static_pointer_cast( + 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()); diff --git a/test/resources/tdm/testdecls/numbers.decl b/test/resources/tdm/testdecls/numbers.decl index 3fbb6f1c05..ca10aa6636 100644 --- a/test/resources/tdm/testdecls/numbers.decl +++ b/test/resources/tdm/testdecls/numbers.decl @@ -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 +}