Refactored test code into tests/ and SDMC tests into its own compilation unit.
This commit is contained in:
parent
24654d71fc
commit
db419e58e9
4
Makefile
4
Makefile
@ -19,9 +19,9 @@ include $(DEVKITARM)/3ds_rules
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
export TARGET := $(shell basename $(CURDIR))
|
export TARGET := $(shell basename $(CURDIR))
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := source
|
SOURCES := source source/tests
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include
|
INCLUDES := source #include
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "test_fs.h"
|
#include "tests/fs.h"
|
||||||
|
|
||||||
static unsigned int testCounter = 0;
|
static unsigned int testCounter = 0;
|
||||||
static void (*tests[]) (void) = {
|
static void (*tests[]) (void) = {
|
||||||
|
23
source/tests/fs.cpp
Normal file
23
source/tests/fs.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "tests/fs_sdmc.h"
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
#include "tests/fs.h"
|
||||||
|
#include "tests/test.h"
|
||||||
|
|
||||||
|
namespace FS {
|
||||||
|
|
||||||
|
void TestAll()
|
||||||
|
{
|
||||||
|
TestResult("FS", "Initializing service", [&]{
|
||||||
|
return fsInit();
|
||||||
|
});
|
||||||
|
|
||||||
|
SDMC::TestAll();
|
||||||
|
|
||||||
|
TestResult("FS", "Exiting service", [&]{
|
||||||
|
return fsExit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
@ -1,12 +1,13 @@
|
|||||||
#include "test_fs.h"
|
#include "tests/fs_sdmc.h"
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include "test.h"
|
#include "tests/test.h"
|
||||||
|
|
||||||
namespace FS {
|
namespace FS {
|
||||||
|
namespace SDMC {
|
||||||
|
|
||||||
static bool TestSDMCFileCreateDelete(FS_archive sdmcArchive)
|
static bool TestFileCreateDelete(FS_archive sdmcArchive)
|
||||||
{
|
{
|
||||||
Handle fileHandle;
|
Handle fileHandle;
|
||||||
const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_create_delete.txt");
|
const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_create_delete.txt");
|
||||||
@ -28,7 +29,7 @@ static bool TestSDMCFileCreateDelete(FS_archive sdmcArchive)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TestSDMCFileRename(FS_archive sdmcArchive)
|
static bool TestFileRename(FS_archive sdmcArchive)
|
||||||
{
|
{
|
||||||
Handle fileHandle;
|
Handle fileHandle;
|
||||||
const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_rename.txt");
|
const static FS_path filePath = FS_makePath(PATH_CHAR, "/test_file_rename.txt");
|
||||||
@ -56,7 +57,7 @@ static bool TestSDMCFileRename(FS_archive sdmcArchive)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TestSDMCFileWrite(FS_archive sdmcArchive)
|
static bool TestFileWrite(FS_archive sdmcArchive)
|
||||||
{
|
{
|
||||||
Handle fileHandle;
|
Handle fileHandle;
|
||||||
u32 bytesWritten;
|
u32 bytesWritten;
|
||||||
@ -82,7 +83,7 @@ static bool TestSDMCFileWrite(FS_archive sdmcArchive)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TestSDMCDirCreateDelete(FS_archive sdmcArchive)
|
static bool TestDirCreateDelete(FS_archive sdmcArchive)
|
||||||
{
|
{
|
||||||
Handle dirHandle;
|
Handle dirHandle;
|
||||||
const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_create_delete");
|
const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_create_delete");
|
||||||
@ -103,7 +104,7 @@ static bool TestSDMCDirCreateDelete(FS_archive sdmcArchive)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool TestSDMCDirRename(FS_archive sdmcArchive)
|
static bool TestDirRename(FS_archive sdmcArchive)
|
||||||
{
|
{
|
||||||
Handle dirHandle;
|
Handle dirHandle;
|
||||||
const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_rename");
|
const static FS_path dirPath = FS_makePath(PATH_CHAR, "/test_dir_rename");
|
||||||
@ -130,7 +131,7 @@ static bool TestSDMCDirRename(FS_archive sdmcArchive)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TestSDMC()
|
void TestAll()
|
||||||
{
|
{
|
||||||
FS_archive sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } };
|
FS_archive sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } };
|
||||||
|
|
||||||
@ -140,23 +141,23 @@ static void TestSDMC()
|
|||||||
});
|
});
|
||||||
|
|
||||||
Test("SDMC", "Creating and deleting file", [&] {
|
Test("SDMC", "Creating and deleting file", [&] {
|
||||||
return TestSDMCFileCreateDelete(sdmcArchive);
|
return TestFileCreateDelete(sdmcArchive);
|
||||||
});
|
});
|
||||||
|
|
||||||
Test("SDMC", "Renaming file", [&] {
|
Test("SDMC", "Renaming file", [&] {
|
||||||
return TestSDMCFileRename(sdmcArchive);
|
return TestFileRename(sdmcArchive);
|
||||||
});
|
});
|
||||||
|
|
||||||
Test("SDMC", "Writing to file", [&] {
|
Test("SDMC", "Writing to file", [&] {
|
||||||
return TestSDMCFileWrite(sdmcArchive);
|
return TestFileWrite(sdmcArchive);
|
||||||
});
|
});
|
||||||
|
|
||||||
Test("SDMC", "Creating and deleting directory", [&] {
|
Test("SDMC", "Creating and deleting directory", [&] {
|
||||||
return TestSDMCDirCreateDelete(sdmcArchive);
|
return TestDirCreateDelete(sdmcArchive);
|
||||||
});
|
});
|
||||||
|
|
||||||
Test("SDMC", "Renaming directory", [&] {
|
Test("SDMC", "Renaming directory", [&] {
|
||||||
return TestSDMCDirRename(sdmcArchive);
|
return TestDirRename(sdmcArchive);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Close SDMC
|
// Close SDMC
|
||||||
@ -165,18 +166,5 @@ static void TestSDMC()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
void TestAll()
|
|
||||||
{
|
|
||||||
TestResult("FS", "Initializing service", [&]{
|
|
||||||
return fsInit();
|
|
||||||
});
|
|
||||||
|
|
||||||
TestSDMC();
|
|
||||||
|
|
||||||
TestResult("FS", "Exiting service", [&]{
|
|
||||||
return fsExit();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
9
source/tests/fs_sdmc.h
Normal file
9
source/tests/fs_sdmc.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace FS {
|
||||||
|
namespace SDMC {
|
||||||
|
|
||||||
|
void TestAll();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user