-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time to start adding tests for things that fail
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
include_directories(${TTVFS_INCLUDE_DIRS}) | ||
|
||
add_executable(test1 test1.cpp) | ||
|
||
target_link_libraries(test1 ttvfs) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:misc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
|
||
#include <ttvfs.h> | ||
#include <cstdio> | ||
|
||
template <typename T> static void assume(const T& what, const char *err) | ||
{ | ||
if(!what) | ||
{ | ||
puts("##### FAILED #####"); | ||
puts(err); | ||
exit(2); | ||
} | ||
} | ||
|
||
static void testmount_shared(ttvfs::Root& vfs) | ||
{ | ||
ttvfs::File *vf = vfs.GetFile("data/file.txt"); | ||
assume(vf, "File not found"); | ||
assume(vf->open("r"), "Failed to open"); | ||
char buf[32]; | ||
assume(vf->read(&buf, sizeof(buf)) == 1, "Failed to read"); | ||
assume(buf[0] == 'B', "Mounted incorrectly - wrong file"); | ||
} | ||
|
||
|
||
static bool testmount1() | ||
{ | ||
puts("- testmount1..."); | ||
ttvfs::Root vfs; | ||
vfs.AddLoader(new ttvfs::DiskLoader); | ||
vfs.Mount("a/data", "data"); | ||
vfs.Mount("b/data", "data"); | ||
vfs.Mount("c/data", "data"); | ||
testmount_shared(vfs); | ||
return true; | ||
} | ||
|
||
static bool testmount2() | ||
{ | ||
puts("- testmount2..."); | ||
ttvfs::Root vfs; | ||
vfs.AddLoader(new ttvfs::DiskLoader); | ||
vfs.Mount("a", ""); | ||
vfs.Mount("b", ""); | ||
vfs.Mount("c", ""); | ||
testmount_shared(vfs); | ||
return true; | ||
} | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
if (testmount1() | ||
&& testmount2() | ||
){ | ||
puts("Tests passed!"); | ||
return 0; | ||
} | ||
|
||
puts("FAIL?!"); | ||
return 1; | ||
} |