Added tests and fixed reading modules and striping names functionality
This commit is contained in:
+44
-7
@@ -1,7 +1,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "unity.h"
|
||||
#include "unity/unity.h"
|
||||
#include "stuffy.h"
|
||||
|
||||
ModuleStruct moduleTest;
|
||||
int argc = 0;
|
||||
char* argv[6];
|
||||
|
||||
@@ -33,30 +35,65 @@ void Test_StuffyArgument_Should_ReturnCorrectly(void)
|
||||
TEST_ASSERT_EQUAL(-1, StuffyArgument(4, argv));
|
||||
}
|
||||
|
||||
void Test_AddToArchive_Should_AddCorrectly(void)
|
||||
void Test_StripFilename_Should_ChangeName(void)
|
||||
{
|
||||
;
|
||||
TEST_ASSERT_EQUAL_STRING("mystuffyarchive.test", StripFilename("test/files/mystuffyarchive.test"));
|
||||
TEST_ASSERT_EQUAL_STRING("temp1.test", StripFilename("test/files/temp1.test"));
|
||||
TEST_ASSERT_EQUAL_STRING("temp2.test", StripFilename("test/files/temp2.test"));
|
||||
TEST_ASSERT_EQUAL_STRING("temp3.test", StripFilename("test/files/temp3.test"));
|
||||
TEST_ASSERT_EQUAL_STRING("temp4.test", StripFilename("test/files/temp4.test"));
|
||||
TEST_ASSERT_EQUAL_STRING("temp5.test", StripFilename("test/files/temp5.test"));
|
||||
}
|
||||
|
||||
void Test_ReadSingleModule_Should_ReadCorrectly(void)
|
||||
{
|
||||
int fd = open(argv[2], O_RDONLY);
|
||||
TEST_ASSERT_EQUAL(80, ReadSingleModule(fd, &moduleTest));
|
||||
TEST_ASSERT_EQUAL(25, ReadSingleModule(fd, &moduleTest));
|
||||
TEST_ASSERT_EQUAL(27, ReadSingleModule(fd, &moduleTest));
|
||||
TEST_ASSERT_EQUAL(27, ReadSingleModule(fd, &moduleTest));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void Test_ReadSingleModule_Should_ReadNewArchive(void)
|
||||
{
|
||||
TEST_IGNORE_MESSAGE("Implementation Required: AddToArchive");
|
||||
int fd = open("test/files/newstuffyarchive.test", O_RDONLY | O_CREAT, 0644);
|
||||
AddToArchive("test/files/newstuffyarchive.test", "temp4.test");
|
||||
TEST_ASSERT_EQUAL(27, ReadSingleModule(fd, &moduleTest));
|
||||
AddToArchive("test/files/newstuffyarchive.test", "temp3.test");
|
||||
TEST_ASSERT_EQUAL(27, ReadSingleModule(fd, &moduleTest));
|
||||
AddToArchive("test/files/newstuffyarchive.test", "temp2.test");
|
||||
TEST_ASSERT_EQUAL(25, ReadSingleModule(fd, &moduleTest));
|
||||
AddToArchive("test/files/newstuffyarchive.test", "temp.test");
|
||||
TEST_ASSERT_EQUAL(80, ReadSingleModule(fd, &moduleTest));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void Test_RemoveFromArchive_Should_RemoveCorrectly(void)
|
||||
{
|
||||
;
|
||||
TEST_IGNORE_MESSAGE("Implementation Required: RemoveFromArchive");
|
||||
}
|
||||
|
||||
void Test_ListArchive_Should_ListCorrectly(void)
|
||||
{
|
||||
;
|
||||
TEST_IGNORE_MESSAGE("Implementation Required: ListArchive");
|
||||
}
|
||||
|
||||
void Test_ExtractArchive_Should_ExtractCorrectly(void)
|
||||
{
|
||||
;
|
||||
TEST_IGNORE_MESSAGE("Implementation Required: ExtractArchive");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
remove("test/files/mystuffyarchive.test");
|
||||
RUN_TEST(Test_StuffyArgument_Should_ReturnCorrectly);
|
||||
RUN_TEST(Test_StripFilename_Should_ChangeName);
|
||||
RUN_TEST(Test_ReadSingleModule_Should_ReadCorrectly);
|
||||
RUN_TEST(Test_ReadSingleModule_Should_ReadNewArchive);
|
||||
RUN_TEST(Test_RemoveFromArchive_Should_RemoveCorrectly);
|
||||
RUN_TEST(Test_ListArchive_Should_ListCorrectly);
|
||||
RUN_TEST(Test_ExtractArchive_Should_ExtractCorrectly);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user