fish/fish_shell_tests/FishCoreTests.cpp

37 lines
974 B
C++
Raw Normal View History

2017-05-15 22:08:07 +00:00
//
// Created by Antoine Bartuccio on 15/05/2017.
//
2017-05-16 00:58:16 +00:00
#include "gtest/gtest.h"
#include "../fish_shell/fish_types.h"
#include "../fish_shell/fish_core.h"
2017-05-15 22:08:07 +00:00
2017-05-15 23:33:36 +00:00
TEST(command_split, split){
2017-05-15 22:08:07 +00:00
char input[] = "git push --force";
char *output[] = {
(char *) "git",
(char *) "push",
(char *) "--force"
};
WordList *list = split(input, (char *) FISH_TOKENS);
WordListElement *current = list->first;
int i = 0;
ASSERT_FALSE(current == NULL);
while(current != NULL){
ASSERT_STREQ(current->word, output[i]);
current = current->next;
i++;
}
freeWordList(list);
}
2017-05-16 00:58:16 +00:00
TEST(count_tokens, countSeparators){
ASSERT_TRUE(countSeparators((char*) "Ceci est un super \n test", (char*) " ") == 5);
ASSERT_TRUE(countSeparators((char*) "patate | patate| patatine", (char*) "\\|") == 2);
ASSERT_TRUE(countSeparators((char*) "patate | patate| patatine |", (char*) "\\|") == 3);
ASSERT_TRUE(countSeparators((char*) "patate | patate|| patatine |", (char*) "\\|[^\\|]") == 2);
2017-05-16 00:58:16 +00:00
}