<commit_before>#include "catch.hpp"

#include "yaml-cpp/yaml.h"
#include "scene/sceneLoader.h"
#include "style/style.h"
#include "scene/scene.h"
#include "platform.h"
#include "tangram.h"

using YAML::Node;
using namespace Tangram;

const char* path = "scene.yaml";

TEST_CASE("Scene update tests") {
    Scene scene("scene.yaml");

    auto sceneString = stringFromFile(setResourceRoot(path).c_str(), PathType::resource);

    REQUIRE(!sceneString.empty());

    Node root;
    REQUIRE(SceneLoader::loadScene(sceneString, scene, root));

    // Update
    scene.setComponent("lights.light1.ambient", "0.9");
    scene.setComponent("lights.light1.type", "spotlight");
    scene.setComponent("lights.light1.origin", "ground");
    scene.setComponent("layers.poi_icons.draw.icons.interactive", "false");
    scene.setComponent("styles.heightglow.shaders.uniforms.u_time_expand", "5.0");
    scene.setComponent("cameras.iso-camera.active", "true");
    scene.setComponent("cameras.iso-camera.type", "perspective");
    scene.setComponent("global.default_order", "function() { return 0.0; }");

    // Tangram apply scene updates, reload the scene
    REQUIRE(SceneLoader::loadScene(sceneString, scene, root));
    scene.clearUserDefines();

    REQUIRE(root["lights"]["light1"]["ambient"].Scalar() == "0.9");
    REQUIRE(root["lights"]["light1"]["type"].Scalar() == "spotlight");
    REQUIRE(root["lights"]["light1"]["origin"].Scalar() == "ground");
    REQUIRE(root["layers"]["poi_icons"]["draw"]["icons"]["interactive"].Scalar() == "false");
    REQUIRE(root["styles"]["heightglow"]["shaders"]["uniforms"]["u_time_expand"].Scalar() == "5.0");
    REQUIRE(root["styles"]["heightglowline"]["shaders"]["uniforms"]["u_time_expand"].Scalar() == "5.0");
    REQUIRE(root["cameras"]["iso-camera"]["active"].Scalar() == "true");
    REQUIRE(root["cameras"]["iso-camera"]["type"].Scalar() == "perspective");
    REQUIRE(root["global"]["default_order"].Scalar() == "function() { return 0.0; }");
}<commit_msg>Unit tests for non-existing YAML property node<commit_after>#include "catch.hpp"

#include "yaml-cpp/yaml.h"
#include "scene/sceneLoader.h"
#include "style/style.h"
#include "scene/scene.h"
#include "platform.h"
#include "tangram.h"

using YAML::Node;
using namespace Tangram;

const char* path = "scene.yaml";

TEST_CASE("Scene update tests") {
    Scene scene("scene.yaml");

    auto sceneString = stringFromFile(setResourceRoot(path).c_str(), PathType::resource);

    REQUIRE(!sceneString.empty());

    Node root;
    REQUIRE(SceneLoader::loadScene(sceneString, scene, root));

    // Update
    scene.setComponent("lights.light1.ambient", "0.9");
    scene.setComponent("lights.light1.type", "spotlight");
    scene.setComponent("lights.light1.origin", "ground");
    scene.setComponent("layers.poi_icons.draw.icons.interactive", "false");
    scene.setComponent("styles.heightglow.shaders.uniforms.u_time_expand", "5.0");
    scene.setComponent("cameras.iso-camera.active", "true");
    scene.setComponent("cameras.iso-camera.type", "perspective");
    scene.setComponent("global.default_order", "function() { return 0.0; }");
    scene.setComponent("global.non_existing_property0", "true");
    scene.setComponent("global.non_existing_property1.non_existing_property_deep", "true");

    // Tangram apply scene updates, reload the scene
    REQUIRE(SceneLoader::loadScene(sceneString, scene, root));
    scene.clearUserDefines();

    REQUIRE(root["lights"]["light1"]["ambient"].Scalar() == "0.9");
    REQUIRE(root["lights"]["light1"]["type"].Scalar() == "spotlight");
    REQUIRE(root["lights"]["light1"]["origin"].Scalar() == "ground");
    REQUIRE(root["layers"]["poi_icons"]["draw"]["icons"]["interactive"].Scalar() == "false");
    REQUIRE(root["styles"]["heightglow"]["shaders"]["uniforms"]["u_time_expand"].Scalar() == "5.0");
    REQUIRE(root["styles"]["heightglowline"]["shaders"]["uniforms"]["u_time_expand"].Scalar() == "5.0");
    REQUIRE(root["cameras"]["iso-camera"]["active"].Scalar() == "true");
    REQUIRE(root["cameras"]["iso-camera"]["type"].Scalar() == "perspective");
    REQUIRE(root["global"]["default_order"].Scalar() == "function() { return 0.0; }");
    REQUIRE(root["global"]["non_existing_property0"].Scalar() == "true");
    REQUIRE(!root["global"]["non_existing_property1"]);
}
{'fraction_non_alphanumeric': 0.21362372567191845, 'fraction_numerical': 0.010194624652455977, 'mean_word_length': 6.030944625407166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '795988', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1471, 'n_words': 189}