Files
GDevelop/Core/tests/ExpressionParser2NaugtyStrings.cpp
Florian Rival a51c223c9c Add experimental, work-in-progress visual editor for custom objects (aka "prefabs"/"templates") (#6699)
* Still to do: 
  * Properly handle effects (disable 3D effects) for layers
  * Handle hot reloading properly
  * Avoid duplicating the configuration of the custom object inside each object created from it. Instead, only store the modified values.
  * Add a "Extract as a custom object ("prefab")" when selecting instances in a scene.
  * Add a dialog to give choice between 2D or 3D object when creating one.
  * Make sure "behavior shared data" are properly handled (physics, pathfinding...)
  * Check if we need to give an expression to translate coordinates from the parent to the local custom object.
  * Ensure a deleted custom object does not break the editor

Co-authored-by: Davy Hélard <davy.helard@gmail.com>
2024-07-11 11:27:34 +02:00

49 lines
1.6 KiB
C++

/*
* GDevelop Core
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
* reserved. This project is released under the MIT License.
*/
#include <fstream>
#include "GDCore/Events/Parsers/ExpressionParser2.h"
#include "DummyPlatform.h"
#include "GDCore/Extensions/Platform.h"
#include "GDCore/Extensions/PlatformExtension.h"
#include "GDCore/IDE/Events/ExpressionValidator.h"
#include "GDCore/Project/Layout.h"
#include "GDCore/Project/Project.h"
#include "catch.hpp"
TEST_CASE("ExpressionParser2 - Naughty strings", "[common][events]") {
gd::Project project;
gd::Platform platform;
SetupProjectWithDummyPlatform(project, platform);
auto &layout1 = project.InsertNewLayout("Layout1", 0);
layout1.GetObjects().InsertNewObject(project, "MyExtension::Sprite",
"MySpriteObject", 0);
gd::ExpressionParser2 parser;
SECTION("Check that no naughty string crash the parser") {
std::string inputFile = std::string(__FILE__) + "-blns.txt";
std::ifstream myfile (inputFile);
std::cout << "Start checking naughty strings... " << std::endl;
if (myfile.is_open()) {
std::string line;
size_t count = 0;
while ( std::getline (myfile,line) ) {
auto node1 = parser.ParseExpression(line.c_str());
REQUIRE(node1 != nullptr);
auto node2 = parser.ParseExpression(line.c_str());
REQUIRE(node2 != nullptr);
count++;
}
myfile.close();
std::cout << "Done (" << count << " strings)." << std::endl;
} else {
FAIL("Can't open " + inputFile);
}
}
}