LightJason - AgentSpeak(L++)
TestCActionMathShape.java
Go to the documentation of this file.
1 /*
2  * @cond LICENSE
3  * ######################################################################################
4  * # LGPL License #
5  * # #
6  * # This file is part of the LightJason AgentSpeak(L++) #
7  * # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8  * # This program is free software: you can redistribute it and/or modify #
9  * # it under the terms of the GNU Lesser General Public License as #
10  * # published by the Free Software Foundation, either version 3 of the #
11  * # License, or (at your option) any later version. #
12  * # #
13  * # This program is distributed in the hope that it will be useful, #
14  * # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15  * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16  * # GNU Lesser General Public License for more details. #
17  * # #
18  * # You should have received a copy of the GNU Lesser General Public License #
19  * # along with this program. If not, see http://www.gnu.org/licenses/ #
20  * ######################################################################################
21  * @endcond
22  */
23 
24 package org.lightjason.agentspeak.action.builtin;
25 
26 import org.junit.Assert;
27 import org.junit.Test;
35 
36 import java.util.ArrayList;
37 import java.util.List;
38 import java.util.stream.Collectors;
39 import java.util.stream.Stream;
40 
44 public final class TestCActionMathShape extends IBaseTest
45 {
46 
50  @Test
51  public final void incircle()
52  {
53  final List<ITerm> l_return = new ArrayList<>();
54 
55  new CInCircle().execute(
56  false, IContext.EMPTYPLAN,
57  Stream.of( 1, 1, 1, 2, 2.5, 0.5, 1 ).map( CRawTerm::from ).collect( Collectors.toList() ),
58  l_return
59  );
60 
61  Assert.assertEquals( l_return.size(), 2 );
62  Assert.assertFalse( l_return.get( 0 ).<Boolean>raw() );
63  Assert.assertTrue( l_return.get( 1 ).<Boolean>raw() );
64  }
65 
69  @Test
70  public final void inrechtangle()
71  {
72  final List<ITerm> l_return = new ArrayList<>();
73 
74  new CInRectangle().execute(
75  false, IContext.EMPTYPLAN,
76  Stream.of( 0, 0, 100, 100, 40, 55, 100, 120 ).map( CRawTerm::from ).collect( Collectors.toList() ),
77  l_return
78  );
79 
80  Assert.assertEquals( l_return.size(), 2 );
81  Assert.assertTrue( l_return.get( 0 ).<Boolean>raw() );
82  Assert.assertFalse( l_return.get( 1 ).<Boolean>raw() );
83  }
84 
88  @Test
89  public final void intriangle()
90  {
91  final List<ITerm> l_return = new ArrayList<>();
92 
93  new CInTriangle().execute(
94  false, IContext.EMPTYPLAN,
95  Stream.of( 250, 220, 25, 275, 40, 55, 60, 170, 310, 129 ).map( CRawTerm::from ).collect( Collectors.toList() ),
96  l_return
97  );
98 
99  Assert.assertEquals( l_return.size(), 2 );
100  Assert.assertTrue( l_return.get( 0 ).<Boolean>raw() );
101  Assert.assertFalse( l_return.get( 1 ).<Boolean>raw() );
102  }
103 
104 }
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
Definition: CInCircle.java:75
base test class with helpers
Definition: IBaseTest.java:33
IContext EMPTYPLAN
empty context with plan
Definition: IContext.java:47
action check if a point within a rectangle.
execution context with local data
Definition: IContext.java:42
action check if a point is within a triangle.
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
action check if a point is within a circle.
Definition: CInCircle.java:51
final IFuzzyValue< Boolean > execute(final boolean p_parallel, @Nonnull final IContext p_context, @Nonnull final List< ITerm > p_argument, @Nonnull final List< ITerm > p_return)
defines a plan-body operation
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
Definition: CRawTerm.java:104
term structure for simple datatypes
Definition: CRawTerm.java:45