Fix empty array construction in cpp (#684)

This commit is contained in:
Awni Hannun
2024-02-13 23:34:17 -08:00
committed by GitHub
parent 0c65517e91
commit 1eb04aa23f
4 changed files with 29 additions and 1 deletions

View File

@@ -591,3 +591,21 @@ TEST_CASE("test array shared buffer") {
eval(a + b);
}
TEST_CASE("test make empty array") {
auto a = array({});
CHECK_EQ(a.size(), 0);
CHECK_EQ(a.dtype(), float32);
a = array({}, int32);
CHECK_EQ(a.size(), 0);
CHECK_EQ(a.dtype(), int32);
a = array({}, float32);
CHECK_EQ(a.size(), 0);
CHECK_EQ(a.dtype(), float32);
a = array({}, bool_);
CHECK_EQ(a.size(), 0);
CHECK_EQ(a.dtype(), bool_);
}