mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
tests: add infrastructure for writing tests in C
This commit is contained in:
parent
e022ca0ce7
commit
60d9b212fb
4 changed files with 92 additions and 0 deletions
59
tests/metacharacters.c
Normal file
59
tests/metacharacters.c
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* metacharacters.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/06 15:21:00 by kcolin #+# #+# */
|
||||
/* Updated: 2025/02/06 15:57:40 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../src/parser/matchers/metacharacter.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void test_metacharacters(void)
|
||||
{
|
||||
dup2(STDERR_FILENO, STDIN_FILENO);
|
||||
char c = 'a';
|
||||
printf("not metachar:");
|
||||
while (c != 'z')
|
||||
{
|
||||
printf("%c", c);
|
||||
assert(!is_metacharacter(c));
|
||||
c++;
|
||||
}
|
||||
c = 'A';
|
||||
while (c != 'Z')
|
||||
{
|
||||
printf("%c", c);
|
||||
assert(!is_metacharacter(c));
|
||||
c++;
|
||||
}
|
||||
c = '0';
|
||||
while (c != '9')
|
||||
{
|
||||
printf("%c", c);
|
||||
assert(!is_metacharacter(c));
|
||||
c++;
|
||||
}
|
||||
char *metachars = " \t\n|&;()<>";
|
||||
int i = 0;
|
||||
printf("\nmetachar:");
|
||||
while (metachars[i] != '\0')
|
||||
{
|
||||
printf("%c", metachars[i]);
|
||||
assert(is_metacharacter(metachars[i]));
|
||||
i++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
test_metacharacters();
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue