Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.analysis

File CodingUtilsTest.java

 

Code metrics

0
35
4
1
100
69
4
0.11
8.75
4
1

Classes

Class Line # Actions
CodingUtilsTest 33 35 4 0
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.analysis;
22   
23    import static org.testng.AssertJUnit.assertEquals;
24    import static org.testng.AssertJUnit.assertTrue;
25   
26    import jalview.gui.JvOptionPane;
27   
28    import java.util.Arrays;
29   
30    import org.testng.annotations.BeforeClass;
31    import org.testng.annotations.Test;
32   
 
33    public class CodingUtilsTest
34    {
35   
 
36  1 toggle @BeforeClass(alwaysRun = true)
37    public void setUpJvOptionPane()
38    {
39  1 JvOptionPane.setInteractiveMode(false);
40  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
41    }
42   
 
43  1 toggle @Test(groups = { "Functional" })
44    public void testDecodeCodon()
45    {
46  1 assertTrue(Arrays.equals(new char[] { 'A', 'A', 'A' },
47    CodingUtils.decodeCodon(0)));
48  1 assertTrue(Arrays.equals(new char[] { 'A', 'A', 'C' },
49    CodingUtils.decodeCodon(1)));
50  1 assertTrue(Arrays.equals(new char[] { 'A', 'A', 'G' },
51    CodingUtils.decodeCodon(2)));
52  1 assertTrue(Arrays.equals(new char[] { 'A', 'A', 'T' },
53    CodingUtils.decodeCodon(3)));
54  1 assertTrue(Arrays.equals(new char[] { 'A', 'C', 'A' },
55    CodingUtils.decodeCodon(4)));
56  1 assertTrue(Arrays.equals(new char[] { 'C', 'A', 'A' },
57    CodingUtils.decodeCodon(16)));
58  1 assertTrue(Arrays.equals(new char[] { 'G', 'G', 'G' },
59    CodingUtils.decodeCodon(42)));
60  1 assertTrue(Arrays.equals(new char[] { 'T', 'T', 'T' },
61    CodingUtils.decodeCodon(63)));
62    }
63   
 
64  1 toggle @Test(groups = { "Functional" })
65    public void testDecodeNucleotide()
66    {
67  1 assertEquals('A', CodingUtils.decodeNucleotide(0));
68  1 assertEquals('C', CodingUtils.decodeNucleotide(1));
69  1 assertEquals('G', CodingUtils.decodeNucleotide(2));
70  1 assertEquals('T', CodingUtils.decodeNucleotide(3));
71  1 assertEquals('0', CodingUtils.decodeNucleotide(4));
72    }
73   
 
74  1 toggle @Test(groups = { "Functional" })
75    public void testEncodeCodon()
76    {
77  1 assertTrue(CodingUtils.encodeCodon('Z') < 0);
78  1 assertEquals(0, CodingUtils.encodeCodon('a'));
79  1 assertEquals(0, CodingUtils.encodeCodon('A'));
80  1 assertEquals(1, CodingUtils.encodeCodon('c'));
81  1 assertEquals(1, CodingUtils.encodeCodon('C'));
82  1 assertEquals(2, CodingUtils.encodeCodon('g'));
83  1 assertEquals(2, CodingUtils.encodeCodon('G'));
84  1 assertEquals(3, CodingUtils.encodeCodon('t'));
85  1 assertEquals(3, CodingUtils.encodeCodon('T'));
86  1 assertEquals(3, CodingUtils.encodeCodon('u'));
87  1 assertEquals(3, CodingUtils.encodeCodon('U'));
88   
89  1 assertEquals(-1, CodingUtils.encodeCodon(null));
90  1 assertEquals(0, CodingUtils.encodeCodon(new char[] { 'A', 'A', 'A' }));
91  1 assertEquals(1, CodingUtils.encodeCodon(new char[] { 'A', 'A', 'C' }));
92  1 assertEquals(2, CodingUtils.encodeCodon(new char[] { 'A', 'A', 'G' }));
93  1 assertEquals(3, CodingUtils.encodeCodon(new char[] { 'A', 'A', 'T' }));
94  1 assertEquals(4, CodingUtils.encodeCodon(new char[] { 'A', 'C', 'A' }));
95  1 assertEquals(16, CodingUtils.encodeCodon(new char[] { 'C', 'A', 'A' }));
96  1 assertEquals(42, CodingUtils.encodeCodon(new char[] { 'G', 'G', 'G' }));
97  1 assertEquals(63, CodingUtils.encodeCodon(new char[] { 'T', 'T', 'T' }));
98    }
99   
100    }