diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-07-31 10:50:51 -0400 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2020-07-31 10:50:51 -0400 |
commit | 956c4b08a3acd9259fdfb33c7f0c11f70c221984 (patch) | |
tree | 10a82bb9a6eb84585c79b428f118978544f58271 /android/sdl_android | |
parent | b54246dbcad27c79eca7d801776c7bb9ec3ee9a5 (diff) | |
download | sdl_android-feature/issue_1407.tar.gz |
Add RPCStruct ClassCastException unit testsfeature/issue_1407
Diffstat (limited to 'android/sdl_android')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java index a61c9558e..5542719ba 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java @@ -155,4 +155,32 @@ public class RPCStructTests extends TestCase { testStruct.setValue(invalidKey, TestValues.GENERAL_STRING); assertNull(testStruct.getObject(Integer.class, invalidKey)); } + + public void testGetFloat() { + Hashtable <String, Object> map = new Hashtable<>(); + String key = "test"; + Double value = 42.00; + map.put(key, value); + RPCStruct rpcStruct = new RPCStruct(map); + try { + Float value2 = rpcStruct.getFloat(key); + assertTrue(value2 - value < 0.1); + } catch (ClassCastException e) { + fail(e.getMessage()); + } + } + + public void testGetDouble() { + Hashtable <String, Object> map = new Hashtable<>(); + String key = "test"; + Integer value = 42; + map.put(key, value); + RPCStruct rpcStruct = new RPCStruct(map); + try { + Double value2 = rpcStruct.getDouble(key); + assertTrue(value2 - value < 0.1); + } catch (ClassCastException e) { + fail(e.getMessage()); + } + } } |