Skip to content

Commit

Permalink
karate.sizeOf() should work for bytes #2310
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Aug 9, 2023
1 parent 6a3f4aa commit 47e49d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ public Object sizeOf(Object o) {
return v.<List>getValue().size();
} else if (v.isMap()) {
return v.<Map>getValue().size();
} else if (v.isBytes()) {
return v.<byte[]>getValue().length;
} else {
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ void testDefAndMatchForArrays() {
);
assertEquals(5, get("arrSize"));
}

@Test
void testSizeOfForByteArrays() {
run(
"bytes data = 'foo'",
"def arrSize = karate.sizeOf(data)"
);
assertEquals(3, get("arrSize"));
}

@Test
void testConfigAndEnv() {
Expand Down

0 comments on commit 47e49d7

Please sign in to comment.