this repo has no description
at trunk 34 lines 815 B view raw
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 2#include "array-module.h" 3 4#include "gtest/gtest.h" 5 6#include "os.h" 7#include "runtime.h" 8#include "test-utils.h" 9 10namespace py { 11 12namespace testing { 13 14using ArrayModuleTest = testing::RuntimeFixture; 15 16TEST_F(ArrayModuleTest, NewCreatesEmptyArrayObject) { 17 ASSERT_FALSE(runFromCStr(runtime_, R"( 18import array 19result = array.array('b') 20)") 21 .isError()); 22 HandleScope scope(thread_); 23 Object result_obj(&scope, mainModuleAt(runtime_, "result")); 24 ASSERT_TRUE(result_obj.isArray()); 25 26 Array result(&scope, *result_obj); 27 ASSERT_EQ(result.length(), 0); 28 ASSERT_TRUE(isStrEqualsCStr(result.typecode(), "b")); 29 ASSERT_EQ(result.buffer(), runtime_->emptyMutableBytes()); 30} 31 32} // namespace testing 33 34} // namespace py