Files
GDevelop/Core/tests/NewNameGenerator.cpp
T
Florian Rival af4145f923 Ensure that two files with the same name are not overwritten when exporting a game.
Refactor name generation with NewNameGenerator.
2015-09-09 15:41:01 +02:00

29 lines
1.0 KiB
C++

/*
* GDevelop Core
* Copyright 2008-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
/**
* @file Tests covering common features of GDevelop Core.
*/
#include "catch.hpp"
#include "GDCore/IDE/NewNameGenerator.h"
#include "GDCore/String.h"
TEST_CASE( "NewNameGenerator", "[common]" ) {
SECTION("Basics") {
REQUIRE(gd::NewNameGenerator::Generate("Test", "abc", [](const gd::String &) {
return false;
}) == "Test");
REQUIRE(gd::NewNameGenerator::Generate("Test", "abc", [](const gd::String & name) {
return name == "Test";
}) == "abcTest");
REQUIRE(gd::NewNameGenerator::Generate("Test", "abc", [](const gd::String & name) {
return name == "Test" || name == "abcTest";
}) == "abcTest2");
REQUIRE(gd::NewNameGenerator::Generate("Test", "abc", [](const gd::String & name) {
return name == "Test" || name == "abcTest" || name == "abcTest2";
}) == "abcTest3");
}
}