mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-07 00:34:42 -04:00
Use a delegate to make OsisParser cleaner
This commit is contained in:
@ -0,0 +1,39 @@
|
||||
package org.bspeice.minimalbible.test;
|
||||
|
||||
import org.bspeice.minimalbible.FinalDelegate;
|
||||
import org.bspeice.minimalbible.MBTestCase;
|
||||
|
||||
import kotlin.PropertyMetadataImpl;
|
||||
|
||||
/**
|
||||
* Test that the FinalDelegate actually obeys its contract
|
||||
*/
|
||||
public class FinalDelegateTest extends MBTestCase {
|
||||
|
||||
FinalDelegate<String> delegate;
|
||||
|
||||
public void setUp() {
|
||||
delegate = new FinalDelegate<String>();
|
||||
}
|
||||
|
||||
public void testDelegateNullSafety() {
|
||||
try {
|
||||
delegate.get(null, new PropertyMetadataImpl(""));
|
||||
} catch (IllegalStateException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
fail("Exception not thrown!");
|
||||
}
|
||||
|
||||
public void testDelegateAssignOnce() {
|
||||
try {
|
||||
delegate.set(null, new PropertyMetadataImpl(""), "");
|
||||
delegate.set(null, new PropertyMetadataImpl(""), "");
|
||||
} catch (IllegalStateException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
fail("Allowed to set twice!");
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ public class OsisParserTest extends MBTestCase {
|
||||
OsisParser parser;
|
||||
|
||||
public void setUp() {
|
||||
parser = new OsisParser(null);
|
||||
parser = new OsisParser();
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
|
Reference in New Issue
Block a user