# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright 2024-2025 Max-Planck-Institut für Nachhaltige Materialien GmbH
# Copyright 2011-2024 Max-Planck-Institut für Eisenforschung GmbH
#
# DAMASK is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
import numpy as np
from numpy import ma

from damask import LoadcaseMesh

def test_dumper():
    a = ma.MaskedArray(np.arange(3,dtype=float),mask=[0,1,0])
    assert str(LoadcaseMesh({'a':a}))             == 'a: [0.0, x, 2.0]\n'
    assert str(LoadcaseMesh({'a':a.astype(int)})) == 'a: [0, x, 2]\n'
    assert str(LoadcaseMesh({'a':a.data}))        == 'a: [0.0, 1.0, 2.0]\n'

def test_init():
    assert LoadcaseMesh() \
        == LoadcaseMesh({
                         'loadstep':[],
                        })
