Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestVector3.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#include <gtest/gtest.h>
9
10#include "arcane/utils/Vector3.h"
11
12/*---------------------------------------------------------------------------*/
13/*---------------------------------------------------------------------------*/
14
15using namespace Arcane;
16
17TEST(TestVector3, Misc)
18{
19 using Int64x3 = Vector3<Int64>;
20
21 {
22 Int64x3 v0;
23 ASSERT_EQ(v0.x, 0);
24 ASSERT_EQ(v0.y, 0);
25 ASSERT_EQ(v0.z, 0);
26 }
27 {
28 Int64x3 v0;
29 Int64x3 v1(2, 7, -5);
30 ASSERT_EQ(v1.x, 2);
31 ASSERT_EQ(v1.y, 7);
32 ASSERT_EQ(v1.z, -5);
33 Int64x3 v2(v1);
34 ASSERT_TRUE(v1 == v2);
35 ASSERT_FALSE(v1 != v2);
36 ASSERT_TRUE(v2 != v0);
37 v0 = v2;
38 ASSERT_TRUE(v2 == v0);
39 std::cout << "V0=" << v0 << "\n";
40 std::cout << "V1=" << v1 << "\n";
41 std::cout << "V2=" << v2 << "\n";
42 ASSERT_FALSE(v0 < v2);
43 ASSERT_FALSE(v2 < v0);
44 Int64x3 v3(1, 5, 4);
45 Int64x3 v4(2, 3, 2);
46 Int64x3 v5(2, 7, 2);
47 ASSERT_TRUE(v3 < v2);
48 ASSERT_TRUE(v4 < v2);
49 ASSERT_TRUE(v4 < v5);
50 }
51 {
52 Int64x3 v1({ 1 });
53 ASSERT_EQ(v1.x, 1);
54 ASSERT_EQ(v1.y, 0);
55 ASSERT_EQ(v1.z, 0);
56 Int64x3 v2({ 1, 2 });
57 ASSERT_EQ(v2.x, 1);
58 ASSERT_EQ(v2.y, 2);
59 ASSERT_EQ(v2.z, 0);
60 Int64x3 v3({ 1, 2, 3 });
61 ASSERT_EQ(v3.x, 1);
62 ASSERT_EQ(v3.y, 2);
63 ASSERT_EQ(v3.z, 3);
64 Int64x3 v4({ 1, 2, 3, 4 });
65 ASSERT_EQ(v4.x, 1);
66 ASSERT_EQ(v4.y, 2);
67 ASSERT_EQ(v4.z, 3);
68 }
69 {
70 Int64x3 v1(1, -2, 4);
71 Int64x3 v2(3, 5, -2);
72 Int64x3 sum_v1_v2(4, 3, 2);
73 Int64x3 mul_v1_4(4, -8, 16);
74 ASSERT_EQ((v1 + 7), Int64x3(8, 5, 11));
75 ASSERT_EQ((7 + v1), Int64x3(8, 5, 11));
76 ASSERT_EQ((v1 - 9), Int64x3(-8, -11, -5));
77 ASSERT_EQ((v1 + v2), sum_v1_v2);
78 Int64x3 v3 = v1;
79 v3 += v2;
81 v3 -= v2;
82 ASSERT_EQ(v3, v1);
83 v3 -= -5;
84 ASSERT_EQ(v3, (v1 + 5));
85 Int64x3 v4 = (v1 * 4);
87 ASSERT_EQ((4 * v1), mul_v1_4);
88 ASSERT_EQ((v4 / 4), v1);
89 Int64x3 v5 = v4;
90 v5 /= 4;
91 ASSERT_EQ(v5, v1);
92 Int64x3 v6 = -v1;
93 ASSERT_EQ(v6, Int64x3(-1, 2, -4));
94 }
95}
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
#define ASSERT_FALSE(condition)
Vérifie que condition est faux.
Definition Assertion.h:138
#define ASSERT_TRUE(condition)
Vérifie que condition est vrai.
Definition Assertion.h:126
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-