From 0a234c9fe8d72b5a4d33955fb607f3bf5f71e0ea Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 13 Aug 2022 09:59:59 +0200 Subject: [PATCH] #6031: Change a few assertions in the MaterialExport tests which were tailored to the old algorithm that replaced the entire decl including the whitespace and comments outside the braced block. --- libs/parser/DefBlockSyntaxParser.h | 2 +- test/MaterialExport.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/parser/DefBlockSyntaxParser.h b/libs/parser/DefBlockSyntaxParser.h index 34d51fb51a..c8bb15d75b 100644 --- a/libs/parser/DefBlockSyntaxParser.h +++ b/libs/parser/DefBlockSyntaxParser.h @@ -323,7 +323,7 @@ class DefBlockSyntax : int nameIndex = static_cast(headerNodes.size()); headerNodes.emplace_back(DefNameSyntax::Create(name)); - headerNodes.emplace_back(DefWhitespaceSyntax::Create(" ")); + headerNodes.emplace_back(DefWhitespaceSyntax::Create("\n")); DefSyntaxToken blockToken(DefSyntaxToken::Type::BracedBlock, "{}"); return std::make_shared(blockToken, std::move(headerNodes), nameIndex, typeIndex); diff --git a/test/MaterialExport.cpp b/test/MaterialExport.cpp index 72e6c52b13..23ac849ef0 100644 --- a/test/MaterialExport.cpp +++ b/test/MaterialExport.cpp @@ -1267,7 +1267,7 @@ TEST_F(MaterialExportTest, WritingMaterialFiles) GlobalMaterialManager().saveMaterial(material->getName()); - EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}")) + EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + " {" + material->getDefinition() + "}")) << "New definition not found in file"; EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition)) << "Original definition still in file"; @@ -1284,7 +1284,9 @@ TEST_F(MaterialExportTest, WritingMaterialFiles) GlobalMaterialManager().saveMaterial(material->getName()); - EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}")) + // Saving doesn't alter any whitespace or comments around the curly braces + EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, + "textures/exporttest/renderBump2 // Comment in the same line as the name (DON'T REMOVE THIS)\n{" + material->getDefinition() + "}")) << "New definition not found in file"; EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition)) << "Original definition still in file"; @@ -1302,7 +1304,10 @@ TEST_F(MaterialExportTest, WritingMaterialFiles) GlobalMaterialManager().saveMaterial(material->getName()); - EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}")) + EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, + "textures/exporttest/renderBump3\n" + " // Comment in between the name and the definition (DON'T REMOVE THIS)\n" + "{" + material->getDefinition() + "}")) << "New definition not found in file"; EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition)) << "Original definition still in file"; @@ -1318,7 +1323,7 @@ TEST_F(MaterialExportTest, WritingMaterialFiles) GlobalMaterialManager().saveMaterial(material->getName()); - EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + "\n{" + material->getDefinition() + "}")) + EXPECT_TRUE(algorithm::fileContainsText(exportTestFile, material->getName() + " {" + material->getDefinition() + "}")) << "New definition not found in file"; EXPECT_FALSE(algorithm::fileContainsText(exportTestFile, originalDefinition)) << "Original definition still in file";