summaryrefslogtreecommitdiff
path: root/source/test/unittests/input_buffer.test.c
blob: c7edb8ffc86e762300c953e8d8df3ddfd24977ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "../../kit/input_buffer.h"

#define KIT_TEST_FILE input_buffer
#include "../../kit_test/test.h"

TEST("input buffer") {
  cstr             text  = { .size = 3, .values = "foo" };
  struct is_handle in    = IS_WRAP_STRING(text);
  struct ib_handle first = IB_WRAP(in);

  struct ib_handle second = ib_read(first, 3);

  REQUIRE(!second.error);
  REQUIRE(second.data.size == 3);
  REQUIRE(AR_EQUAL(text, second.data));

  ib_destroy(second);
  ib_destroy(first);
  is_destroy(in);
}