input: add test single_arg_too_large
This commit is contained in:
parent
2accea96f0
commit
6454c63441
21
test/input.c
21
test/input.c
|
@ -1,8 +1,6 @@
|
||||||
#include "greatest.h"
|
#include "greatest.h"
|
||||||
#include "../input.h"
|
#include "../input.h"
|
||||||
|
|
||||||
#define s(x) {x, sizeof(x) - 1}
|
|
||||||
|
|
||||||
TEST one_pass(void) {
|
TEST one_pass(void) {
|
||||||
struct libscomm_input in;
|
struct libscomm_input in;
|
||||||
char s[] = "Arg 1\tArg \r\v\t!\n";
|
char s[] = "Arg 1\tArg \r\v\t!\n";
|
||||||
|
@ -23,23 +21,36 @@ TEST one_pass(void) {
|
||||||
PASS();
|
PASS();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
TEST single_arg_too_large(void) {
|
TEST single_arg_too_large(void) {
|
||||||
struct libscomm_input in;
|
struct libscomm_input in;
|
||||||
struct libscomm_inbuf b;
|
|
||||||
struct libscomm_line l;
|
struct libscomm_line l;
|
||||||
char s[LIBSCOMM_MAXBUF + 12];
|
char s[LIBSCOMM_MAXBUF + 12];
|
||||||
|
char *p;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int ostate;
|
||||||
|
|
||||||
for (i = 0; i < sizeof s; i++)
|
for (i = 0; i < sizeof s; i++)
|
||||||
s[i] = 'a';
|
s[i] = 'a';
|
||||||
|
s[sizeof s - 2] = '\n';
|
||||||
|
s[sizeof s - 1] = 0;
|
||||||
|
p = s;
|
||||||
|
|
||||||
|
libscomm_reset(&in);
|
||||||
|
ASSERT_EQ(libscomm_read(&in, &p, &l), LIBSCOMM_OVERFLOW);
|
||||||
|
ASSERT_EQ(in.len, 0);
|
||||||
|
|
||||||
|
/* state values are opaque. */
|
||||||
|
ostate = in.state;
|
||||||
|
libscomm_reset(&in);
|
||||||
|
ASSERT_EQ(ostate, in.state);
|
||||||
|
PASS();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
GREATEST_MAIN_DEFS();
|
GREATEST_MAIN_DEFS();
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
GREATEST_MAIN_BEGIN();
|
GREATEST_MAIN_BEGIN();
|
||||||
RUN_TEST(one_pass);
|
RUN_TEST(one_pass);
|
||||||
|
RUN_TEST(single_arg_too_large);
|
||||||
GREATEST_MAIN_END();
|
GREATEST_MAIN_END();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue