forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ElektraInitiative#3725 from aaronabebe/master
[CM H1] added two small jna tests
- Loading branch information
Showing
5 changed files
with
108 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/bindings/jna/libelektra5j/src/test/java/org/libelektra/KeyNameIteratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.libelektra; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.Iterator; | ||
import org.junit.Test; | ||
|
||
public class KeyNameIteratorTest | ||
{ | ||
|
||
static final String KEY_1_NAME = "/key_test/1/key_name"; | ||
static final String KEY_1_NAME_PART_1 = "\u0001"; | ||
static final String KEY_1_NAME_PART_2 = "key_test"; | ||
static final String KEY_1_NAME_PART_3 = "1"; | ||
static final String KEY_1_NAME_PART_4 = "key_name"; | ||
static final String KEY_1_VALUE = "key_value_1"; | ||
|
||
@Test public void test_keyNameIteratorHasNext_shouldPass () | ||
{ | ||
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE); | ||
final Iterator<String> iterator = key.iterator (); | ||
assertTrue (iterator.hasNext ()); | ||
assertEquals (KEY_1_NAME_PART_1, iterator.next ()); | ||
assertTrue (iterator.hasNext ()); | ||
assertEquals (KEY_1_NAME_PART_2, iterator.next ()); | ||
assertTrue (iterator.hasNext ()); | ||
assertEquals (KEY_1_NAME_PART_3, iterator.next ()); | ||
assertTrue (iterator.hasNext ()); | ||
assertEquals (KEY_1_NAME_PART_4, iterator.next ()); | ||
assertFalse (iterator.hasNext ()); | ||
} | ||
|
||
@Test (expected = UnsupportedOperationException.class) public void test_keyNameIteratorDelete_shouldPass () | ||
{ | ||
final Key key = Key.create (KEY_1_NAME, KEY_1_VALUE); | ||
final Iterator<String> iterator = key.iterator (); | ||
assertTrue (iterator.hasNext ()); | ||
iterator.remove (); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/bindings/jna/libelektra5j/src/test/java/org/libelektra/plugin/ReturnTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.libelektra.plugin; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.libelektra.Key; | ||
import org.libelektra.KeySet; | ||
|
||
public class ReturnTest | ||
{ | ||
|
||
static final String ERROR_KEY_NAME = "/temporary/errorkey"; | ||
static final String ERROR_KEY_VALUE = "error"; | ||
|
||
private Return returnPlugin; | ||
private Key errorKey; | ||
|
||
@Before public void setup () | ||
{ | ||
returnPlugin = new Return (); | ||
errorKey = Key.create (ERROR_KEY_NAME, ERROR_KEY_VALUE); | ||
} | ||
|
||
@Test public void test_returnOpen_shouldBeCode0 () | ||
{ | ||
KeySet config = returnPlugin.getConfig (); | ||
int open = returnPlugin.open (config, errorKey); | ||
assertEquals (0, open); | ||
} | ||
|
||
@Test public void test_returnGet_ShouldBeCode10 () | ||
{ | ||
KeySet config = returnPlugin.getConfig (); | ||
int open = returnPlugin.get (config, errorKey); | ||
assertEquals (10, open); | ||
} | ||
|
||
@Test public void test_returnSet_ShouldBeCode20 () | ||
{ | ||
KeySet config = returnPlugin.getConfig (); | ||
int open = returnPlugin.set (config, errorKey); | ||
assertEquals (20, open); | ||
} | ||
|
||
@Test public void test_returnError_ShouldBeCode30 () | ||
{ | ||
KeySet config = returnPlugin.getConfig (); | ||
int open = returnPlugin.error (config, errorKey); | ||
assertEquals (30, open); | ||
} | ||
|
||
@Test public void test_returnClose_ShouldBeCode0 () | ||
{ | ||
int open = returnPlugin.close (errorKey); | ||
assertEquals (0, open); | ||
} | ||
|
||
@Test public void test_returnGetName_ShouldBeReturn () | ||
{ | ||
assertEquals (Return.PLUGIN_NAME, returnPlugin.getName ()); | ||
} | ||
} |