/**
* @file tests/common_value.cpp
* @author The ARTIS Development Team
* See the AUTHORS or Authors.txt file
*/
/*
* ARTIS - the multimodeling and simulation environment
* This file is a part of the ARTIS environment
*
* Copyright (C) 2013-2022 ULCO http://www.univ-littoral.fr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "artis-star/common/event/Value.hpp"
#define BOOST_TEST_MODULE Common_Value_Tests
#include
/*************************************************
* Tests
*************************************************/
BOOST_AUTO_TEST_CASE(Common_Value_TestCase_1)
{
artis::common::event::Value first_value{1};
artis::common::event::Value second_value{1};
BOOST_CHECK(first_value == second_value);
}
BOOST_AUTO_TEST_CASE(Common_Value_TestCase_2)
{
artis::common::event::Value int_value{1};
artis::common::event::Value unsigned_int_value{(unsigned int) 1};
artis::common::event::Value double_value{0.5};
artis::common::event::Value bool_value{true};
artis::common::event::Value char_value{'a'};
BOOST_REQUIRE_EQUAL(int_value.to_string(), "1");
BOOST_REQUIRE_EQUAL(unsigned_int_value.to_string(), "1");
BOOST_REQUIRE_EQUAL(double_value.to_string(), "0.500000");
BOOST_REQUIRE_EQUAL(bool_value.to_string(), "true");
BOOST_REQUIRE_EQUAL(char_value.to_string(), "a");
}
BOOST_AUTO_TEST_CASE(Common_Value_TestCase_3)
{
int int_values[] = {1, 2, 3};
artis::common::event::Value int_value{int_values, 3};
unsigned int unsigned_int_values[] = {1, 2, 3};
artis::common::event::Value unsigned_int_value{unsigned_int_values, 3};
double double_values[] = {0.5, 0.6, 1.2};
artis::common::event::Value double_value{double_values, 3};
bool bool_values[] = {true, false, true, false};
artis::common::event::Value bool_value{bool_values, 4};
char char_values[] = {'a', 'b', 'c'};
artis::common::event::Value char_value{char_values, 3};
BOOST_REQUIRE_EQUAL(int_value.to_string(), "1 2 3 ");
BOOST_REQUIRE_EQUAL(unsigned_int_value.to_string(), "1 2 3 ");
BOOST_REQUIRE_EQUAL(double_value.to_string(), "0.500000 0.600000 1.200000 ");
BOOST_REQUIRE_EQUAL(bool_value.to_string(), "true false true false ");
BOOST_REQUIRE_EQUAL(char_value.to_string(), "abc");
}
BOOST_AUTO_TEST_CASE(Common_Value_TestCase_4)
{
struct S {
} s;
artis::common::event::Value value{s};
BOOST_REQUIRE_EQUAL(value.to_string(), "");
}