d1aa37a4f5a7b788fd2822ce6a4f8739d4f7747d
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 private static CTFCallsite
GenerateCS(long ip
){
50 return new CTFCallsite("event name", "func name", ip
, "file.java", 1);
54 * Test the constructor
57 public void constructorTest(){
58 CTFCallsite cs
= GenerateCS(0x01);
63 * Test the comparator (it should sort using the IP)
66 public void comparatorTest(){
67 CTFCallsite cs
[] = new CTFCallsite
[5];
68 long vals
[] = {1L, 0L, -2L, 2L, -1L};
69 for(int i
= 0 ; i
< 5 ; i
++ ){
70 cs
[i
] = GenerateCS(vals
[i
]);
73 assertEquals(1, cs
[0].compareTo(cs
[1]));
74 assertEquals(-1, cs
[1].compareTo(cs
[0]));
75 assertEquals(0, cs
[0].compareTo(cs
[0]));
76 assertEquals(-1, cs
[0].compareTo(cs
[2]));
77 assertEquals(1, cs
[2].compareTo(cs
[0]));
81 assertEquals( 0L, cs
[0].getIp());
82 assertEquals( 1L, cs
[1].getIp());
83 assertEquals( 2L, cs
[2].getIp());
84 assertEquals( -2L , cs
[3].getIp());
85 assertEquals( -1L, cs
[4].getIp());
89 * Tests the output of a callsite toString function
92 public void toStringTest(){
93 CTFCallsite cs
= GenerateCS(0x01);
94 assertEquals("file.java/func name:1", cs
.toString());
101 * the command line arguments
103 public static void main(String
[] args
) {
104 new org
.junit
.runner
.JUnitCore().run(CTFCallsiteTest
.class);
This page took 0.033244 seconds and 5 git commands to generate.