1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.event
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
6 import java
.util
.Arrays
;
8 import org
.eclipse
.linuxtools
.ctf
.core
.event
.CTFCallsite
;
9 import org
.junit
.After
;
10 import org
.junit
.Before
;
11 import org
.junit
.Test
;
14 * The class <code>CTFCallsiteTest</code> contains tests for the class
15 * <code>{@link CTFCallsite}</code>.
17 * @author Matthew Khouzam
18 * @version $Revision: 1.0 $
21 public class CTFCallsiteTest
{
23 * Perform pre-test initialization.
27 // add additional set up code here
31 * Perform post-test clean-up.
34 public void tearDown() {
35 // Add additional tear down code here
38 @SuppressWarnings("nls")
39 private static CTFCallsite
GenerateCS(long ip
){
40 return new CTFCallsite("event name", "func name", ip
, "file.java", 1);
44 * Test the constructor
47 public void constructorTest(){
48 CTFCallsite cs
= GenerateCS(0x01);
53 * Test the comparator (it should sort using the IP)
56 public void comparatorTest(){
57 CTFCallsite cs
[] = new CTFCallsite
[5];
58 long vals
[] = {1L, 0L, -2L, 2L, -1L};
59 for(int i
= 0 ; i
< 5 ; i
++ ){
60 cs
[i
] = GenerateCS(vals
[i
]);
63 assertEquals(1, cs
[0].compareTo(cs
[1]));
64 assertEquals(-1, cs
[1].compareTo(cs
[0]));
65 assertEquals(0, cs
[0].compareTo(cs
[0]));
66 assertEquals(-1, cs
[0].compareTo(cs
[2]));
67 assertEquals(1, cs
[2].compareTo(cs
[0]));
71 assertEquals( 0L, cs
[0].getIp());
72 assertEquals( 1L, cs
[1].getIp());
73 assertEquals( 2L, cs
[2].getIp());
74 assertEquals( -2L , cs
[3].getIp());
75 assertEquals( -1L, cs
[4].getIp());
79 * Tests the output of a callsite toString function
82 public void toStringTest(){
83 CTFCallsite cs
= GenerateCS(0x01);
84 assertEquals("file.java/func name:1", cs
.toString()); //$NON-NLS-1$
91 * the command line arguments
93 public static void main(String
[] args
) {
94 new org
.junit
.runner
.JUnitCore().run(CTFCallsiteTest
.class);
This page took 0.033415 seconds and 5 git commands to generate.