| 1 | package org.eclipse.linuxtools.ctf.core.tests.types; |
| 2 | |
| 3 | import static org.junit.Assert.assertNotNull; |
| 4 | |
| 5 | import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer; |
| 6 | import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope; |
| 7 | import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration; |
| 8 | import org.eclipse.linuxtools.ctf.core.event.types.StringDefinition; |
| 9 | import org.junit.After; |
| 10 | import org.junit.Before; |
| 11 | import org.junit.Test; |
| 12 | |
| 13 | /** |
| 14 | * The class <code>StringDefinitionTest</code> contains tests for the class |
| 15 | * <code>{@link StringDefinition}</code>. |
| 16 | * |
| 17 | * @author ematkho |
| 18 | * @version $Revision: 1.0 $ |
| 19 | */ |
| 20 | public class StringDefinitionTest { |
| 21 | |
| 22 | private StringDefinition fixture; |
| 23 | |
| 24 | /** |
| 25 | * Launch the test. |
| 26 | * |
| 27 | * @param args |
| 28 | * the command line arguments |
| 29 | */ |
| 30 | public static void main(String[] args) { |
| 31 | new org.junit.runner.JUnitCore().run(StringDefinitionTest.class); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Perform pre-test initialization. |
| 36 | */ |
| 37 | @Before |
| 38 | public void setUp() { |
| 39 | String name = "testString"; //$NON-NLS-1$ |
| 40 | StringDeclaration stringDec = new StringDeclaration(); |
| 41 | fixture = stringDec.createDefinition(null, name); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Perform post-test clean-up. |
| 46 | */ |
| 47 | @After |
| 48 | public void tearDown() { |
| 49 | // Add additional tear down code here |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Run the StringDefinition(StringDeclaration,DefinitionScope,String) |
| 54 | * constructor test. |
| 55 | */ |
| 56 | @Test |
| 57 | public void testStringDefinition() { |
| 58 | StringDeclaration declaration = new StringDeclaration(); |
| 59 | IDefinitionScope definitionScope = null; |
| 60 | String fieldName = ""; //$NON-NLS-1$ |
| 61 | |
| 62 | StringDefinition result = new StringDefinition(declaration, |
| 63 | definitionScope, fieldName); |
| 64 | |
| 65 | assertNotNull(result); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Run the StringDeclaration getDeclaration() method test. |
| 70 | */ |
| 71 | @Test |
| 72 | public void testGetDeclaration() { |
| 73 | fixture.setString(new StringBuilder()); |
| 74 | StringDeclaration result = fixture.getDeclaration(); |
| 75 | assertNotNull(result); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Run the StringBuilder getString() method test. |
| 80 | */ |
| 81 | @Test |
| 82 | public void testGetString() { |
| 83 | fixture.setString(new StringBuilder()); |
| 84 | StringBuilder result = fixture.getString(); |
| 85 | assertNotNull(result); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Run the String getValue() method test. |
| 90 | */ |
| 91 | @Test |
| 92 | public void testGetValue() { |
| 93 | fixture.setString(new StringBuilder()); |
| 94 | String result = fixture.getValue(); |
| 95 | assertNotNull(result); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Run the void read(BitBuffer) method test. |
| 100 | */ |
| 101 | @Test |
| 102 | public void testRead() { |
| 103 | fixture.setString(new StringBuilder()); |
| 104 | BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128)); |
| 105 | fixture.read(input); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Run the void setDeclaration(StringDeclaration) method test. |
| 110 | */ |
| 111 | @Test |
| 112 | public void testSetDeclaration() { |
| 113 | fixture.setString(new StringBuilder()); |
| 114 | StringDeclaration declaration = new StringDeclaration(); |
| 115 | fixture.setDeclaration(declaration); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Run the void setString(StringBuilder) method test. |
| 120 | */ |
| 121 | @Test |
| 122 | public void testSetString() { |
| 123 | fixture.setString(new StringBuilder()); |
| 124 | StringBuilder string = new StringBuilder(); |
| 125 | fixture.setString(string); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Run the String toString() method test. |
| 130 | */ |
| 131 | @Test |
| 132 | public void testToString() { |
| 133 | fixture.setString(new StringBuilder()); |
| 134 | String result = fixture.toString(); |
| 135 | assertNotNull(result); |
| 136 | } |
| 137 | } |