Make Test a template function for easy comparison with values.
Also allows further logging and output in the future.
This commit is contained in:
parent
38a0c47d43
commit
3f083e0e0e
@ -111,11 +111,11 @@ static bool Ssax() {
|
||||
void TestAll() {
|
||||
const std::string tag = "Integer";
|
||||
|
||||
Test(tag, "ADD", &Add);
|
||||
Test(tag, "SUB", &Sub);
|
||||
Test(tag, "MUL", &Mul);
|
||||
Test(tag, "SASX", &Sasx);
|
||||
Test(tag, "SSAX", &Ssax);
|
||||
Test(tag, "ADD", Add(), true);
|
||||
Test(tag, "SUB", Sub(), true);
|
||||
Test(tag, "MUL", Mul(), true);
|
||||
Test(tag, "SASX", Sasx(), true);
|
||||
Test(tag, "SSAX", Ssax(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,15 +8,11 @@ namespace FS {
|
||||
|
||||
void TestAll()
|
||||
{
|
||||
TestResult("FS", "Initializing service", [&]{
|
||||
return fsInit();
|
||||
});
|
||||
Test("FS", "Initializing service", fsInit(), 0L);
|
||||
|
||||
SDMC::TestAll();
|
||||
|
||||
TestResult("FS", "Exiting service", [&]{
|
||||
return fsExit();
|
||||
});
|
||||
Test("FS", "Exiting service", fsExit(), 0L);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -145,35 +145,13 @@ void TestAll()
|
||||
{
|
||||
FS_archive sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } };
|
||||
|
||||
// Open SDMC
|
||||
TestResult("SDMC", "Opening archive", [&]{
|
||||
return FSUSER_OpenArchive(NULL, &sdmcArchive);
|
||||
});
|
||||
|
||||
Test("SDMC", "Creating and deleting file", [&] {
|
||||
return TestFileCreateDelete(sdmcArchive);
|
||||
});
|
||||
|
||||
Test("SDMC", "Renaming file", [&] {
|
||||
return TestFileRename(sdmcArchive);
|
||||
});
|
||||
|
||||
Test("SDMC", "Writing and reading file", [&] {
|
||||
return TestFileWriteRead(sdmcArchive);
|
||||
});
|
||||
|
||||
Test("SDMC", "Creating and deleting directory", [&] {
|
||||
return TestDirCreateDelete(sdmcArchive);
|
||||
});
|
||||
|
||||
Test("SDMC", "Renaming directory", [&] {
|
||||
return TestDirRename(sdmcArchive);
|
||||
});
|
||||
|
||||
// Close SDMC
|
||||
TestResult("SDMC", "Closing archive", [&]{
|
||||
return FSUSER_CloseArchive(NULL, &sdmcArchive);
|
||||
});
|
||||
Test("SDMC", "Opening archive", FSUSER_OpenArchive(NULL, &sdmcArchive), 0L);
|
||||
Test("SDMC", "Creating and deleting file", TestFileCreateDelete(sdmcArchive), true);
|
||||
Test("SDMC", "Renaming file", TestFileRename(sdmcArchive), true);
|
||||
Test("SDMC", "Writing and reading file", TestFileWriteRead(sdmcArchive), true);
|
||||
Test("SDMC", "Creating and deleting directory", TestDirCreateDelete(sdmcArchive), true);
|
||||
Test("SDMC", "Renaming directory", TestDirRename(sdmcArchive), true);
|
||||
Test("SDMC", "Closing archive", FSUSER_CloseArchive(NULL, &sdmcArchive), 0L);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -4,12 +4,7 @@
|
||||
|
||||
#include "output.h"
|
||||
|
||||
void Test(std::string group, std::string name, std::function<bool (void)> test)
|
||||
void PrintSuccess(std::string group, std::string name, bool val)
|
||||
{
|
||||
print(GFX_TOP, "%s: %s - %s\n", group.c_str(), name.c_str(), test() ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
||||
void TestResult(std::string group, std::string name, std::function<int (void)> test)
|
||||
{
|
||||
print(GFX_TOP, "%s: %s - %s\n", group.c_str(), name.c_str(), test() == 0 ? "SUCCESS" : "FAILURE");
|
||||
print(GFX_TOP, "%s: %s - %s\n", group.c_str(), name.c_str(), val ? "SUCCESS" : "FAILURE");
|
||||
}
|
||||
|
@ -5,6 +5,11 @@
|
||||
// If the condition fails, return false
|
||||
#define SoftAssert(cond) do { if (!(cond)) { return false; } } while (0)
|
||||
|
||||
void Test(std::string group, std::string name, std::function<bool (void)> test);
|
||||
void PrintSuccess(std::string group, std::string name, bool val);
|
||||
|
||||
void TestResult(std::string group, std::string name, std::function<int (void)> test);
|
||||
template <typename T>
|
||||
bool Test(std::string group, std::string name, T result, T expected)
|
||||
{
|
||||
PrintSuccess(group, name, result == expected);
|
||||
return result == expected;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user