| 1 | /* |
| 2 | * Copyright (C) - EfficiOS, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by as |
| 6 | * published by the Free Software Foundation; only version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License along with |
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 15 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 | */ |
| 17 | |
| 18 | #include <common/buffer-view.h> |
| 19 | #include <tap/tap.h> |
| 20 | |
| 21 | static const int TEST_COUNT = 5; |
| 22 | |
| 23 | /* For error.h */ |
| 24 | int lttng_opt_quiet = 1; |
| 25 | int lttng_opt_verbose; |
| 26 | int lttng_opt_mi; |
| 27 | |
| 28 | static void test_validate_string(void) |
| 29 | { |
| 30 | const char buf[] = {'A', 'l', 'l', 'o', '\0'}; |
| 31 | struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5); |
| 32 | struct lttng_buffer_view view_minus_one = |
| 33 | lttng_buffer_view_init(buf, 0, 4); |
| 34 | |
| 35 | ok1(!lttng_buffer_view_validate_string(&view, buf, 4)); |
| 36 | ok1(lttng_buffer_view_validate_string(&view, buf, 5)); |
| 37 | ok1(!lttng_buffer_view_validate_string(&view, buf, 6)); |
| 38 | |
| 39 | ok1(!lttng_buffer_view_validate_string(&view_minus_one, buf, 4)); |
| 40 | ok1(!lttng_buffer_view_validate_string(&view_minus_one, buf, 5)); |
| 41 | } |
| 42 | |
| 43 | int main(void) |
| 44 | { |
| 45 | plan_tests(TEST_COUNT); |
| 46 | |
| 47 | test_validate_string(); |
| 48 | |
| 49 | return exit_status(); |
| 50 | } |