diff options
author | Colin Snover | 2017-09-21 16:30:22 -0500 |
---|---|---|
committer | Eugene Sandulenko | 2017-09-30 11:17:53 +0200 |
commit | 4938d5cc76b0ba1037be1b9b589dd2093c62509f (patch) | |
tree | 4ceab840b86bbffe635e1007ede5abc6bb747424 /test/common | |
parent | c867a1834ff9ac08214b19e34a71aeae215f00a4 (diff) | |
download | scummvm-rg350-4938d5cc76b0ba1037be1b9b589dd2093c62509f.tar.gz scummvm-rg350-4938d5cc76b0ba1037be1b9b589dd2093c62509f.tar.bz2 scummvm-rg350-4938d5cc76b0ba1037be1b9b589dd2093c62509f.zip |
COMMON: Add standard data method to Common::Array
This matches the C++11 std::vector method of the same name, and
replaces usage of taking the address of the first element of an
array by &array[0] or &array.front() or &*array.begin(). The data
method is better than these usages because it can be used even
when the array is empty.
Diffstat (limited to 'test/common')
-rw-r--r-- | test/common/array.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/common/array.h b/test/common/array.h index 7506162821..45be99371f 100644 --- a/test/common/array.h +++ b/test/common/array.h @@ -353,6 +353,15 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(array2.size(), (unsigned int)3); } + void test_data() { + Common::Array<int> array; + TS_ASSERT(array.data() == nullptr); + array.resize(2); + TS_ASSERT(array.data() != nullptr); + TS_ASSERT_EQUALS(array.data(), &array.front()); + TS_ASSERT_EQUALS(array.data() + array.size() - 1, &array.back()); + } + void test_front_back_push_pop() { Common::Array<int> container; |