1 package net.obsearch.index.pyramid.impl;
2
3 import static org.junit.Assert.*;
4
5 import net.obsearch.index.pptree.SpaceTreeLeaf;
6
7 import org.junit.Before;
8 import org.junit.Test;
9
10 /*
11 OBSearch: a distributed similarity search engine
12 This project is to similarity search what 'bit-torrent' is to downloads.
13 Copyright (C) 2007 Arnoldo Jose Muller Molina
14
15 This program is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 */
28 /**
29 * Test the SpaceTreeLeaf object.
30 * @author Arnoldo Jose Muller Molina
31 * @since 0.7
32 */
33
34 public class TestSpaceTreeLeaf {
35
36 /**
37 * Leaf that will be tested.
38 */
39 private SpaceTreeLeaf leaf;
40
41 /**
42 * Prepare a space vector to test if a point
43 * belongs or not.
44 */
45 @Before
46 public void setUp() throws Exception {
47 double [] center = {.75f,.75f};
48 leaf = new SpaceTreeLeaf(center);
49 double[][] space = { { 0.5f, 1 }, { 0.5f, 1 } };
50 leaf.setMinMax(space);
51 }
52
53 /**
54 * Make sure that intersects works well.
55 */
56 @Test
57 public void testIntersects() {
58 double[][] test = { { -1, 0.6f }, { -1, 0.7f } };
59 assertTrue(leaf.intersects(test));
60 }
61 /**
62 * Make sure that intersects works well.
63 */
64 @Test
65 public void testNotIntersects() {
66 double[][] test = { { -1, 0.4f }, { -1, 0.3f } };
67 assertFalse(leaf.intersects(test));
68 }
69
70 }