https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 68f182c58738c298fe6dd88600e79db03d7c2f3b authored by Dmitry Yu. Naumov on 05 October 2016, 21:47:36 UTC
Merge pull request #1463 from chleh/improve-docu-part5
Tip revision: 68f182c
TestUniqueMeshId.cpp
/**
 * \copyright
 * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/LICENSE.txt
 */

#include "gtest/gtest.h"

#include "MeshLib/Mesh.h"

using namespace MeshLib;

TEST(MeshLib, UniqueMeshId)
{
    // Create first mesh and get the current counter value.
    Mesh m0("first", std::vector<Node*>(), std::vector<Element*>());
    std::size_t const counter_value = m0.getID();

    EXPECT_GE(counter_value, 0u);

    //
    // Test mesh counter increments.
    //
    Mesh* m1 = new Mesh("second", std::vector<Node*>(), std::vector<Element*>());
    ASSERT_EQ(counter_value + std::size_t(1), m1->getID());

    Mesh m2("third", std::vector<Node*>(), std::vector<Element*>());
    ASSERT_EQ(counter_value + std::size_t(2), m2.getID());

    delete m1;
    ASSERT_EQ(counter_value + std::size_t(2), m2.getID());

    Mesh m3("fourth", std::vector<Node*>(), std::vector<Element*>());
    ASSERT_EQ(counter_value + std::size_t(3), m3.getID());

    // Copy mesh keeps also increments the counter.
    Mesh m4 = m0;
    ASSERT_EQ(counter_value + std::size_t(4), m4.getID());

}

back to top