Merge branch 'rc' of github.com:thingsboard/thingsboard into rc
This commit is contained in:
commit
dfbc8f1cde
@ -1697,6 +1697,62 @@ class TbelInvokeDocsIoTest extends AbstractTbelInvokeTest {
|
|||||||
assertEquals(4.2d, actual);
|
assertEquals(4.2d, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bitwise Operations
|
||||||
|
@Test
|
||||||
|
public void bitwiseOperationsBoolean_Test() throws ExecutionException, InterruptedException {
|
||||||
|
msgStr = "{}";
|
||||||
|
decoderStr = """
|
||||||
|
var x = true;
|
||||||
|
var y = false;
|
||||||
|
return {
|
||||||
|
"andResult": x & y,
|
||||||
|
"orResult": x | y,
|
||||||
|
"xorResult": x ^ y,
|
||||||
|
"leftShift": x << y,
|
||||||
|
"rightShift": x >> y,
|
||||||
|
"rightUnShift": x >>> y
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
LinkedHashMap<String, Object> expected = new LinkedHashMap<>();
|
||||||
|
expected.put("andResult", 0);
|
||||||
|
expected.put("orResult", 1);
|
||||||
|
expected.put("xorResult", 1);
|
||||||
|
expected.put("leftShift", 1);
|
||||||
|
expected.put("rightShift", 1);
|
||||||
|
expected.put("rightUnShift", 1);
|
||||||
|
Object actual = invokeScript(evalScript(decoderStr), msgStr);
|
||||||
|
assertEquals(expected, actual);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void bitwiseOperationsMix_Test() throws ExecutionException, InterruptedException {
|
||||||
|
msgStr = "{}";
|
||||||
|
decoderStr = """
|
||||||
|
var x = true;
|
||||||
|
var y = false;
|
||||||
|
var i = 10;
|
||||||
|
var b = -14;
|
||||||
|
var l = 9223372036854775807;
|
||||||
|
return {
|
||||||
|
"andResult": x & b,
|
||||||
|
"orResult": i | y,
|
||||||
|
"xorResult": i ^ l,
|
||||||
|
"leftShift": l << i,
|
||||||
|
"rightShift": l >> b,
|
||||||
|
"rightUnShift": i >>> x
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
LinkedHashMap<String, Object> expected = new LinkedHashMap<>();
|
||||||
|
expected.put("andResult", 0);
|
||||||
|
expected.put("orResult", 10);
|
||||||
|
expected.put("xorResult", 9223372036854775797L);
|
||||||
|
expected.put("leftShift", -1024L);
|
||||||
|
expected.put("rightShift", 8191L);
|
||||||
|
expected.put("rightUnShift", 5);
|
||||||
|
Object actual = invokeScript(evalScript(decoderStr), msgStr);
|
||||||
|
assertEquals(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// base64
|
// base64
|
||||||
@Test
|
@Test
|
||||||
public void base64_Test() throws ExecutionException, InterruptedException {
|
public void base64_Test() throws ExecutionException, InterruptedException {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user