37451940c3ddec2baadc31ba777bf02dc44fd561
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.event
;
14 import static org
.junit
.Assert
.assertEquals
;
15 import static org
.junit
.Assert
.assertNotNull
;
17 import java
.util
.Arrays
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.event
.CTFCallsite
;
20 import org
.junit
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * The class <code>CTFCallsiteTest</code> contains tests for the class
26 * <code>{@link CTFCallsite}</code>.
28 * @author Matthew Khouzam
29 * @version $Revision: 1.0 $
32 public class CTFCallsiteTest
{
34 * Perform pre-test initialization.
38 // add additional set up code here
42 * Perform post-test clean-up.
45 public void tearDown() {
46 // Add additional tear down code here
49 @SuppressWarnings("nls")
50 private static CTFCallsite
GenerateCS(long ip
){
51 return new CTFCallsite("event name", "func name", ip
, "file.java", 1);
55 * Test the constructor
58 public void constructorTest(){
59 CTFCallsite cs
= GenerateCS(0x01);
64 * Test the comparator (it should sort using the IP)
67 public void comparatorTest(){
68 CTFCallsite cs
[] = new CTFCallsite
[5];
69 long vals
[] = {1L, 0L, -2L, 2L, -1L};
70 for(int i
= 0 ; i
< 5 ; i
++ ){
71 cs
[i
] = GenerateCS(vals
[i
]);
74 assertEquals(1, cs
[0].compareTo(cs
[1]));
75 assertEquals(-1, cs
[1].compareTo(cs
[0]));
76 assertEquals(0, cs
[0].compareTo(cs
[0]));
77 assertEquals(-1, cs
[0].compareTo(cs
[2]));
78 assertEquals(1, cs
[2].compareTo(cs
[0]));
82 assertEquals( 0L, cs
[0].getIp());
83 assertEquals( 1L, cs
[1].getIp());
84 assertEquals( 2L, cs
[2].getIp());
85 assertEquals( -2L , cs
[3].getIp());
86 assertEquals( -1L, cs
[4].getIp());
90 * Tests the output of a callsite toString function
93 public void toStringTest(){
94 CTFCallsite cs
= GenerateCS(0x01);
95 assertEquals("file.java/func name:1", cs
.toString()); //$NON-NLS-1$
102 * the command line arguments
104 public static void main(String
[] args
) {
105 new org
.junit
.runner
.JUnitCore().run(CTFCallsiteTest
.class);
This page took 0.048606 seconds and 5 git commands to generate.