Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91400200
test_tuples.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 10, 18:10
Size
2 KB
Mime Type
text/x-c
Expires
Tue, Nov 12, 18:10 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22257630
Attached To
rLIBMULTISCALE LibMultiScale
test_tuples.cc
View Options
/**
* @file test_tuples.cc
*
* @author Nicolas Richart
*
* @date creation mar déc 10 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* akantu-iterators is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* akantu-iterators 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with akantu-iterators. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_tuple_tools.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
/* -------------------------------------------------------------------------- */
using namespace aka;
using namespace aka::tuple;
TEST(NamedTuples, GNUExtension) {
const auto a = std::vector<int>{1, 10, 3};
const auto test = make_named_tuple(
"nom"_n = std::string("Roger"), "age"_n = 47, "taille"_n = 1.92,
"liste"_n = std::vector<int>({1, 2, 3}), "ref"_n = a);
auto nom = test.get("nom"_n);
EXPECT_EQ(47, test.get("age"_n));
EXPECT_EQ("Roger", nom);
EXPECT_EQ(1.92, test.get("taille"_n));
EXPECT_EQ(a.data(), test.get("ref"_n).data());
}
TEST(NamedTuples, WithHash) {
const auto a = std::vector<int>{1, 10, 3};
const auto tuple = make_named_tuple(
get<"nom"_h>() = std::string("Roger"), get<"age"_h>() = 47, get<"taille"_h>() = 1.92,
get<"liste"_h>() = std::vector<int>({1, 2, 3}), get<"ref"_h>() = a);
EXPECT_EQ(47, tuple::get<"age"_h>(tuple));
EXPECT_EQ("Roger", tuple::get<"nom"_h>(tuple));
EXPECT_EQ(1.92, tuple::get<"taille"_h>(tuple));
EXPECT_EQ(a.data(), tuple::get<"ref"_h>(tuple).data());
}
Event Timeline
Log In to Comment