diff options
Diffstat (limited to 'gdb/unittests')
-rw-r--r-- | gdb/unittests/array-view-selftests.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c index 74defa1..746062c 100644 --- a/gdb/unittests/array-view-selftests.c +++ b/gdb/unittests/array-view-selftests.c @@ -496,6 +496,28 @@ run_tests () for (size_t i = 0; i < len; i++) SELF_CHECK (view[i] == data[i]); } + + /* Test slicing. */ + { + gdb_byte data[] = {0x55, 0x66, 0x77, 0x88, 0x99}; + gdb::array_view<gdb_byte> view = data; + + { + auto slc = view.slice (1, 3); + SELF_CHECK (slc.data () == data + 1); + SELF_CHECK (slc.size () == 3); + SELF_CHECK (slc[0] == data[1]); + SELF_CHECK (slc[0] == view[1]); + } + + { + auto slc = view.slice (2); + SELF_CHECK (slc.data () == data + 2); + SELF_CHECK (slc.size () == 3); + SELF_CHECK (slc[0] == view[2]); + SELF_CHECK (slc[0] == data[2]); + } + } } } /* namespace array_view_tests */ |