File: grok_manymanymany.test.c

package info (click to toggle)
grok 1.20110708.1-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,388 kB
  • sloc: ansic: 3,469; ruby: 987; makefile: 276; sh: 124; yacc: 106
file content (24 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "grok.h"
#include "test.h"
#include <string.h>

void test_manymanymany(void) {
  INIT;
  IMPORT_PATTERNS_FILE;

  int i;
  grok_match_t gm;
  const char *str;
  int len;
  ASSERT_COMPILEOK("%{NUMBER}");

  for (i = -10000; i < 10000; i++) {
    char buf[30];
    sprintf(buf, "%d", i);
    CU_ASSERT(grok_exec(&grok, buf, &gm) == GROK_OK);
    grok_match_get_named_substring(&gm, "NUMBER", &str, &len);
    CU_ASSERT(strncmp(str, buf, len) == 0);
  }

  CLEANUP;
}