mirror of
https://github.com/johnkerl/miller.git
synced 2026-08-02 12:32:21 +00:00
[read performance iterate] byte-reader intf/impls
This commit is contained in:
parent
e65418002c
commit
eead5e3a6c
4 changed files with 37 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,6 +5,7 @@ mlrp
|
|||
mlr-unit-tester
|
||||
test-mlrutil
|
||||
test-string-builder
|
||||
test-string-byte-reader
|
||||
test-lrec
|
||||
test-join-bucket-keeper
|
||||
termcvt
|
||||
|
|
|
|||
9
c/input/byte_readers.h
Normal file
9
c/input/byte_readers.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef BYTE_READERS_H
|
||||
#define BYTE_READERS_H
|
||||
#include "input/byte_reader.h"
|
||||
|
||||
byte_reader_t* string_byte_reader_alloc();
|
||||
|
||||
void string_byte_reader_free(byte_reader_t* pbr);
|
||||
|
||||
#endif // BYTE_READERS_H
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include <stdio.h> // For definition of EOF
|
||||
#include "input/byte_reader.h"
|
||||
#include "input/byte_readers.h"
|
||||
#include "lib/mlrutil.h"
|
||||
|
||||
typedef struct _string_byte_reader_state_t {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "lib/minunit.h"
|
||||
#include "lib/mlrutil.h"
|
||||
#include "containers/lrec.h"
|
||||
#include "containers/sllv.h"
|
||||
#include "input/lrec_readers.h"
|
||||
#include "lib/minunit.h"
|
||||
#include "input/byte_readers.h"
|
||||
|
||||
#ifdef __TEST_STRING_BYTE_READER_MAIN__
|
||||
int tests_run = 0;
|
||||
|
|
@ -14,9 +12,30 @@ int assertions_failed = 0;
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
static char* test_it() {
|
||||
mu_assert_lf(0 == 0);
|
||||
mu_assert_lf(1 == 1);
|
||||
mu_assert_lf(2 == 2);
|
||||
byte_reader_t* pbr = string_byte_reader_alloc();
|
||||
|
||||
int ok = pbr->popen_func(pbr, "");
|
||||
mu_assert_lf(ok == TRUE);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
pbr->pclose_func(pbr);
|
||||
|
||||
ok = pbr->popen_func(pbr, "a");
|
||||
mu_assert_lf(ok == TRUE);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == 'a');
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
pbr->pclose_func(pbr);
|
||||
|
||||
ok = pbr->popen_func(pbr, "abc");
|
||||
mu_assert_lf(ok == TRUE);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == 'a');
|
||||
mu_assert_lf(pbr->pread_func(pbr) == 'b');
|
||||
mu_assert_lf(pbr->pread_func(pbr) == 'c');
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
mu_assert_lf(pbr->pread_func(pbr) == EOF);
|
||||
pbr->pclose_func(pbr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue