97 lines
2.3 KiB
C
97 lines
2.3 KiB
C
#include <criterion/criterion.h>
|
|
#include <criterion/new/assert.h>
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "utils/string_utils/string_utils.h"
|
|
|
|
TestSuite(string_utils);
|
|
|
|
Test(string_utils, skipblank_basic)
|
|
{
|
|
char input[] = " Hello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 2;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_noblank)
|
|
{
|
|
char input[] = "Hello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 0;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_tab)
|
|
{
|
|
char input[] = "\tHello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 1;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_space_tab)
|
|
{
|
|
char input[] = " \tHello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 2;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_2tab_1space)
|
|
{
|
|
char input[] = "\t \tHello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 3;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_a_lot)
|
|
{
|
|
char input[] = "\t \t \tHello World";
|
|
char expected_str[] = "Hello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 8;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_newline)
|
|
{
|
|
char input[] = "\nHello World";
|
|
char expected_str[] = "\nHello World";
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 0;
|
|
cr_expect(eq(str, input, expected_str));
|
|
cr_expect(actual == expected);
|
|
}
|
|
|
|
Test(string_utils, skipblank_nul)
|
|
{
|
|
char *input = NULL;
|
|
|
|
ssize_t actual = skip_blanks(input);
|
|
ssize_t expected = 0;
|
|
cr_expect(input == NULL);
|
|
cr_expect(actual == expected);
|
|
}
|