Skip to content
Snippets Groups Projects
Commit 93204f69 authored by Jaewon Choi's avatar Jaewon Choi
Browse files

Add testing functionality

parent 6e12e126
No related branches found
No related tags found
No related merge requests found
#ifndef MYSH_UTILS_H_
#define MYSH_UTILS_H_
void mysh_parse_command(const char* command,
int *argc, char** argv);
#endif // MYSH_UTILS_H_
int main()
{
return 0;
}
#include "utils.h"
void mysh_parse_command(const char* command,
int *argc, char** argv)
{
// TODO: Fill this!
}
extern "C" {
#include "utils.h"
}
#include "gtest/gtest.h" #include "gtest/gtest.h"
TEST(CommandParsingTest, Basic) { #include <stdlib.h>
EXPECT_EQ(1, 1);
TEST(CommandParsingTest, BasicCommand) {
char** argv;
int argc = -1;
argv = (char**)malloc(2);
for (int i = 0; i < 2; ++i) {
argv[i] = (char*)malloc(512);
}
mysh_parse_command("cd test", &argc, argv);
EXPECT_EQ(argc, 2);
EXPECT_STREQ(argv[0], "cd");
EXPECT_STREQ(argv[1], "test");
for (int i = 0; i < 2; ++i) {
free(argv[i]);
}
free(argv);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment