Skip to content

Commit

Permalink
[Tests] Add MemRef container 2D array test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghb97 committed Sep 27, 2024
1 parent 1db26c9 commit 409e32c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/Interface/core/ContainerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main() {
MemRef<float, 3> testArrayNoMallocConstructor(arrayShape, false, 0);
// CHECK: {{(nil)|0x0}}
fprintf(stderr, "%p\n", testArrayNoMallocConstructor.getData());

//===--------------------------------------------------------------------===//
// Test array constructor.
//===--------------------------------------------------------------------===//
Expand All @@ -77,6 +77,16 @@ int main() {
// CHECK: 5.0
fprintf(stderr, "%f\n", testArrayConstructor[5]);

//===--------------------------------------------------------------------===//
// Test 2-D array constructor.
//===--------------------------------------------------------------------===//
float data2D[2][3] = {{0.0, 1.0, 2.0}, {0.0, 1.0, 2.0}};
MemRef<float, 2> test2DArrayConstructor(&data2D[0][0], sizes);
// CHECK: 0.0
fprintf(stderr, "%f\n", test2DArrayConstructor.getData()[0]);
// CHECK: 1.0
fprintf(stderr, "%f\n", test2DArrayConstructor[4]);

//===--------------------------------------------------------------------===//
// Test copy constructor and copy assignment operator.
//===--------------------------------------------------------------------===//
Expand Down Expand Up @@ -118,7 +128,6 @@ int main() {
//===--------------------------------------------------------------------===//
// Test overloading bracket operator.
//===--------------------------------------------------------------------===//

float data1[6] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
MemRef<float, 2> testBracketOperator1(data1, sizes);
// CHECK: 0.0
Expand Down

0 comments on commit 409e32c

Please sign in to comment.