Add condition-targeting error query
[lttng-tools.git] / tests / unit / test_buffer_view.c
1 /*
2 * Copyright (C) 2020 EfficiOS, inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8
9 #include <common/buffer-view.h>
10 #include <tap/tap.h>
11
12 static const int TEST_COUNT = 5;
13
14 /* For error.h */
15 int lttng_opt_quiet = 1;
16 int lttng_opt_verbose;
17 int lttng_opt_mi;
18
19 static void test_contains_string(void)
20 {
21 const char buf[] = {'A', 'l', 'l', 'o', '\0'};
22 struct lttng_buffer_view view = lttng_buffer_view_init(buf, 0, 5);
23 struct lttng_buffer_view view_minus_one =
24 lttng_buffer_view_init(buf, 0, 4);
25
26 ok1(!lttng_buffer_view_contains_string(&view, buf, 4));
27 ok1(lttng_buffer_view_contains_string(&view, buf, 5));
28 ok1(!lttng_buffer_view_contains_string(&view, buf, 6));
29
30 ok1(!lttng_buffer_view_contains_string(&view_minus_one, buf, 4));
31 ok1(!lttng_buffer_view_contains_string(&view_minus_one, buf, 5));
32 }
33
34 int main(void)
35 {
36 plan_tests(TEST_COUNT);
37
38 test_contains_string();
39
40 return exit_status();
41 }
This page took 0.031087 seconds and 4 git commands to generate.