1 /*
2  * Copyright (C) 2012 John May <jwmay@users.sf.net>
3  *
4  * Contact: cdk-devel@lists.sourceforge.net
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version. All we ask is that proper credit is given for our
10  * work, which includes - but is not limited to - adding the above copyright
11  * notice to the beginning of your source code files, and to any copyright
12  * notice that you may distribute with programs based on this work.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23 package org.openscience.cdk.ringsearch;
24 
25 import org.junit.Test;
26 import org.openscience.cdk.interfaces.IAtomContainer;
27 import org.openscience.cdk.templates.TestMoleculeFactory;
28 
29 import java.util.List;
30 
31 import static org.hamcrest.CoreMatchers.is;
32 import static org.junit.Assert.assertThat;
33 import static org.junit.Assert.assertTrue;
34 
35 /**
36  * biphenyl ring search unit tests
37  *
38  * @author John May
39  * @cdk.module test-standard
40  */
41 public final class RingSearchTest_Biphenyl {
42 
43     private final IAtomContainer biphenyl = TestMoleculeFactory.makeBiphenyl();
44 
45     @Test
testCyclic()46     public void testCyclic() {
47         assertThat(new RingSearch(biphenyl).cyclic().length, is(biphenyl.getAtomCount()));
48     }
49 
50     @Test
testCyclic_Int()51     public void testCyclic_Int() {
52         int n = biphenyl.getAtomCount();
53         RingSearch ringSearch = new RingSearch(biphenyl);
54         for (int i = 0; i < n; i++) {
55             assertTrue(ringSearch.cyclic(i));
56         }
57     }
58 
59     @Test
testIsolated()60     public void testIsolated() {
61         RingSearch search = new RingSearch(biphenyl);
62         int[][] isolated = search.isolated();
63         assertThat(isolated.length, is(2));
64         assertThat(isolated[0].length, is(6));
65         assertThat(isolated[1].length, is(6));
66     }
67 
68     @Test
testFused()69     public void testFused() {
70         assertThat(new RingSearch(biphenyl).fused().length, is(0));
71     }
72 
73     @Test
testRingFragments()74     public void testRingFragments() {
75         IAtomContainer fragment = new RingSearch(biphenyl).ringFragments();
76         assertThat(fragment.getAtomCount(), is(biphenyl.getAtomCount()));
77         assertThat(fragment.getBondCount(), is(biphenyl.getBondCount() - 1));
78     }
79 
80     @Test
testIsolatedRingFragments()81     public void testIsolatedRingFragments() {
82         RingSearch search = new RingSearch(biphenyl);
83         List<IAtomContainer> isolated = search.isolatedRingFragments();
84         assertThat(isolated.size(), is(2));
85         assertThat(isolated.get(0).getAtomCount(), is(6));
86         assertThat(isolated.get(0).getBondCount(), is(6));
87         assertThat(isolated.get(1).getAtomCount(), is(6));
88         assertThat(isolated.get(1).getBondCount(), is(6));
89     }
90 
91     @Test
testFusedRingFragments()92     public void testFusedRingFragments() {
93         RingSearch search = new RingSearch(biphenyl);
94         List<IAtomContainer> fused = search.fusedRingFragments();
95         assertThat(fused.size(), is(0));
96     }
97 
98 }
99