mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added parser tests
This commit is contained in:
parent
4d35031cb0
commit
e7478d8cb8
@ -367,5 +367,3 @@ get_start(char *string, int tokens)
|
||||
|
||||
return result_str;
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,6 +279,124 @@ parse_cmd_freetext_with_many_quoted_and_many_spaces(void)
|
||||
assert_string_equals("and heres the free text", result[2]);
|
||||
g_strfreev(result);
|
||||
}
|
||||
|
||||
void
|
||||
count_one_token(void)
|
||||
{
|
||||
char *inp = "one";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(1, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_one_token_quoted_no_whitespace(void)
|
||||
{
|
||||
char *inp = "\"one\"";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(1, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_one_token_quoted_with_whitespace(void)
|
||||
{
|
||||
char *inp = "\"one two\"";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(1, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_two_tokens(void)
|
||||
{
|
||||
char *inp = "one two";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_two_tokens_first_quoted(void)
|
||||
{
|
||||
char *inp = "\"one and\" two";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_two_tokens_second_quoted(void)
|
||||
{
|
||||
char *inp = "one \"two and\"";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_two_tokens_both_quoted(void)
|
||||
{
|
||||
char *inp = "\"one and then\" \"two and\"";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equals(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_of_one(void)
|
||||
{
|
||||
char *inp = "one";
|
||||
char *result = get_start(inp, 2);
|
||||
|
||||
assert_string_equals("one", result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_of_two(void)
|
||||
{
|
||||
char *inp = "one two";
|
||||
char *result = get_start(inp, 2);
|
||||
|
||||
assert_string_equals("one ", result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_two_of_three(void)
|
||||
{
|
||||
char *inp = "one two three";
|
||||
char *result = get_start(inp, 3);
|
||||
|
||||
assert_string_equals("one two ", result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_two_of_three_first_quoted(void)
|
||||
{
|
||||
char *inp = "\"one\" two three";
|
||||
char *result = get_start(inp, 3);
|
||||
|
||||
assert_string_equals("\"one\" two ", result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_two_of_three_second_quoted(void)
|
||||
{
|
||||
char *inp = "one \"two\" three";
|
||||
char *result = get_start(inp, 3);
|
||||
|
||||
assert_string_equals("one \"two\" ", result);
|
||||
}
|
||||
|
||||
void
|
||||
get_first_two_of_three_first_and_second_quoted(void)
|
||||
{
|
||||
char *inp = "\"one\" \"two\" three";
|
||||
char *result = get_start(inp, 3);
|
||||
|
||||
assert_string_equals("\"one\" \"two\" ", result);
|
||||
}
|
||||
|
||||
void
|
||||
register_parser_tests(void)
|
||||
{
|
||||
@ -307,4 +425,17 @@ register_parser_tests(void)
|
||||
TEST(parse_cmd_freetext_with_quoted_and_space);
|
||||
TEST(parse_cmd_freetext_with_quoted_and_many_spaces);
|
||||
TEST(parse_cmd_freetext_with_many_quoted_and_many_spaces);
|
||||
TEST(count_one_token);
|
||||
TEST(count_one_token_quoted_no_whitespace);
|
||||
TEST(count_one_token_quoted_with_whitespace);
|
||||
TEST(count_two_tokens);
|
||||
TEST(count_two_tokens_first_quoted);
|
||||
TEST(count_two_tokens_second_quoted);
|
||||
TEST(count_two_tokens_both_quoted);
|
||||
TEST(get_first_of_one);
|
||||
TEST(get_first_of_two);
|
||||
TEST(get_first_two_of_three);
|
||||
TEST(get_first_two_of_three_first_quoted);
|
||||
TEST(get_first_two_of_three_second_quoted);
|
||||
TEST(get_first_two_of_three_first_and_second_quoted);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user