コード例 #1
0
static void
_test_value_separator_clone(void)
{
  KVScanner *scanner = kv_scanner_new();
  kv_scanner_set_value_separator(scanner, ':');
  KVScanner *cloned_scanner = kv_scanner_clone(scanner);
  kv_scanner_free(scanner);

  TEST_KV_SCANNER(cloned_scanner, "key1:value1 key2:value2 key3:value3 ",
                  "key1", "value1",
                  "key2", "value2",
                  "key3", "value3");
  kv_scanner_free(cloned_scanner);
}
コード例 #2
0
static void
_scan_kv_pairs_implicit(const gchar *input, VAElement args[])
{
  KVScanner *scanner = kv_scanner_new();
  _scan_kv_pairs_scanner(scanner, input, args);
  kv_scanner_free(scanner);
}
コード例 #3
0
static void
_test_transforms_values_if_parse_value_is_set(void)
{
  KVScanner *scanner = kv_scanner_new();
  scanner->parse_value = _parse_value_by_incrementing_all_bytes;
  TEST_KV_SCANNER(scanner, "foo=\"bar\"", "foo", "cbs");
  kv_scanner_free(scanner);
}
コード例 #4
0
ファイル: kv-parser.c プロジェクト: rvadim/syslog-ng
static void
kv_parser_free(LogPipe *s)
{
  KVParser *self = (KVParser *)s;

  kv_scanner_free(self->kv_scanner);
  g_string_free(self->formatted_key, TRUE);
  g_free(self->prefix);
  log_parser_free_method(s);
}
コード例 #5
0
static void
_test_value_separator_with_whitespaces_around(void)
{
  KVScanner *scanner = kv_scanner_new();
  kv_scanner_set_value_separator(scanner, ':');

  TEST_KV_SCANNER(scanner, "key1: value1 key2 : value2 key3 :value3 ",
                  "key1", "");

  kv_scanner_free(scanner);
}
コード例 #6
0
static void
_test_separator_in_key(void)
{
  KVScanner *scanner = kv_scanner_new();
  kv_scanner_set_value_separator(scanner, '-');

  TEST_KV_SCANNER(scanner, "k-v", "k", "v");
  TEST_KV_SCANNER(scanner, "k--v", "k", "-v");
  TEST_KV_SCANNER(scanner, "---", "-", "-");

  kv_scanner_free(scanner);
}
コード例 #7
0
static void
_test_value_separator_is_used_to_separate_key_from_value(void)
{
  KVScanner *scanner = kv_scanner_new();
  kv_scanner_set_value_separator(scanner, ':');

  TEST_KV_SCANNER(scanner, "key1:value1 key2:value2 key3:value3 ",
                  "key1", "value1",
                  "key2", "value2",
                  "key3", "value3");

  kv_scanner_free(scanner);
}
コード例 #8
0
static void
_scan_kv_pairs_quoted(const gchar *input, KVQContainer args)
{
  KVScanner *scanner = kv_scanner_new();

  g_assert(input);
  kv_scanner_input(scanner, input);
  gboolean expect_more = TRUE;
  for (gsize i = 0; i < args.n; i++)
    {
      if (!_compare_key_value(scanner, args.arg[i].key, args.arg[i].value, &expect_more))
        break;
      expect_gboolean(scanner->value_was_quoted, args.arg[i].quoted,
                      "mismatch in value_was_quoted for [%s/%s]",
                      args.arg[i].key, args.arg[i].value);
    }
  if (expect_more)
    _assert_no_more_tokens(scanner);
  kv_scanner_free(scanner);
}