Skip to content

Commit

Permalink
Fix unit test and add test_copy_packed_implicit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivorforce committed Sep 25, 2024
1 parent 7161293 commit 08110b5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 7 additions & 3 deletions test/project/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ func _ready():
PackedInt32Array([3, 4])
])

# Packed array append
# Packed array handling
assert_equal(
example.test_append_to_packed(PackedInt32Array([1, 2])),
PackedInt32Array([1, 2, 3]),
example.test_append_to_packed(PackedByteArray([1, 2])),
PackedByteArray([1, 2, 3]),
)
assert_equal(
example.test_copy_packed_implicit(),
[PackedInt32Array([1]), PackedInt32Array([1, 2])],
)

# PackedArray iterators
Expand Down
18 changes: 17 additions & 1 deletion test/src/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,28 @@ TypedArray<PackedInt32Array> Example::test_typed_array_of_packed() const {
return arr;
}

PackedInt32Array test_append_to_packed(const PackedInt32Array& packed) const {
PackedByteArray test_append_to_packed(const PackedByteArray& packed) const {
PackedByteArray b = PackedByteArray(a);
b.append(3);
return b;
}

TypedArray<PackedInt32Array> test_copy_packed_implicit() const {
PackedInt32Array a;
a.append(1);

PackedInt32Array b = a;
b.append(2);

Array arr;

arr.resize(2);
arr[0] = a;
arr[1] = b;

return arr;
}

int Example::test_vector_ops() const {
PackedInt32Array arr;
arr.push_back(10);
Expand Down
3 changes: 2 additions & 1 deletion test/src/example.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class Example : public Control {
bool test_string_is_forty_two(const String &p_str) const;
String test_string_resize(String p_original) const;
TypedArray<PackedInt32Array> test_typed_array_of_packed() const;
PackedInt32Array test_append_to_packed(const PackedInt32Array& packed) const;
PackedByteArray test_append_to_packed(const PackedByteArray& packed) const;
TypedArray<PackedInt32Array> test_copy_packed_implicit() const;
int test_vector_ops() const;
int test_vector_init_list() const;

Expand Down

0 comments on commit 08110b5

Please sign in to comment.