mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
Util.cppの自動テスト追加
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@221 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
7c5b20eec6
commit
b5dafc263c
@ -14,7 +14,6 @@
|
|||||||
# $Rev$
|
# $Rev$
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
#.SUBDIRS: $(glob D, *)
|
|
||||||
.SUBDIRS: $(exist-dirs \
|
.SUBDIRS: $(exist-dirs \
|
||||||
common \
|
common \
|
||||||
ConsoleBackup \
|
ConsoleBackup \
|
||||||
@ -22,4 +21,7 @@
|
|||||||
tools \
|
tools \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if $(IsTestBuild)
|
||||||
|
.SUBDIRS: $(exist-dirs tests)
|
||||||
|
|
||||||
DefineDefaultRules()
|
DefineDefaultRules()
|
||||||
|
|||||||
38
trunk/ConsoleDataMigration/sources/tests/OMakefile
Normal file
38
trunk/ConsoleDataMigration/sources/tests/OMakefile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env omake
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Project: Horizon
|
||||||
|
# File: OMakefile
|
||||||
|
#
|
||||||
|
# Copyright (C)2009 Nintendo Co., Ltd. All rights reserved.
|
||||||
|
#
|
||||||
|
# These coded instructions, statements, and computer programs contain
|
||||||
|
# proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
# Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
# not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
# in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
#
|
||||||
|
# $Rev$
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
SUPPORTED_TARGETS = CTR-*.Process.MPCore.*
|
||||||
|
|
||||||
|
include $(makePlatformDefsPath tests)
|
||||||
|
|
||||||
|
INCLUDES += \
|
||||||
|
../common
|
||||||
|
|
||||||
|
TEST_COMMON_SOURCES[] =
|
||||||
|
../common/Util.cpp
|
||||||
|
|
||||||
|
SOURCES_TEST[] = test_Util.cpp
|
||||||
|
|
||||||
|
ROMFS_ROOT = ../common/romfiles
|
||||||
|
|
||||||
|
TEST_ENVIRONMENT_PROCESSLIST = true
|
||||||
|
TEST_ENVIRONMENT_EMUMEM = true
|
||||||
|
|
||||||
|
LIBS += libnn_test
|
||||||
|
|
||||||
|
include $(makePlatformDefsPath build.tests)
|
||||||
|
|
||||||
|
|
||||||
|
tests: $(TEST_TARGETS)
|
||||||
90
trunk/ConsoleDataMigration/sources/tests/test_Util.cpp
Normal file
90
trunk/ConsoleDataMigration/sources/tests/test_Util.cpp
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
Project: Horizon
|
||||||
|
File: test_Util.cpp
|
||||||
|
|
||||||
|
Copyright 2009 Nintendo. All rights reserved.
|
||||||
|
|
||||||
|
These coded instructions, statements, and computer programs contain
|
||||||
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||||
|
Company Ltd., and are protected by Federal copyright law. They may
|
||||||
|
not be disclosed to third parties or copied or duplicated in any form,
|
||||||
|
in whole or in part, without the prior written consent of Nintendo.
|
||||||
|
|
||||||
|
$Rev$
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <nn.h>
|
||||||
|
#include <nn/test/test_Test.h>
|
||||||
|
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||||
|
|
||||||
|
#include "Util.h"
|
||||||
|
|
||||||
|
using namespace nn::test;
|
||||||
|
|
||||||
|
class UtilTest : public Suite {
|
||||||
|
public:
|
||||||
|
virtual bool InitializeSuite();
|
||||||
|
virtual void FinalizeSuite();
|
||||||
|
|
||||||
|
UtilTest() {
|
||||||
|
SUITE_NAME("TestUtil");
|
||||||
|
TEST_ADD(UtilTest::AddCheckDigit);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void AddCheckDigit();
|
||||||
|
};
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Initialize/Finalize
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool UtilTest::InitializeSuite()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UtilTest::FinalizeSuite()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Test Util
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Test Functions
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
void UtilTest::AddCheckDigit()
|
||||||
|
{
|
||||||
|
|
||||||
|
// 通常チェックデジット
|
||||||
|
{
|
||||||
|
const char serialBase[] = "EJF10000445";
|
||||||
|
const char serialWithCheckDigit[] = "EJF100004458";
|
||||||
|
char serial[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||||||
|
std::memcpy(serial, serialBase, sizeof(serialBase));
|
||||||
|
common::Util::AddCheckDigit(serial);
|
||||||
|
|
||||||
|
NN_TEST_ASSERT_EQUAL(std::strcmp(serial, serialWithCheckDigit), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// チェックデジットが0になる場合
|
||||||
|
{
|
||||||
|
const char serialBase[] = "CJF10004638";
|
||||||
|
const char serialWithCheckDigit[] = "CJF100046380";
|
||||||
|
char serial[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||||||
|
std::memcpy(serial, serialBase, sizeof(serialBase));
|
||||||
|
common::Util::AddCheckDigit(serial);
|
||||||
|
|
||||||
|
NN_TEST_ASSERT_EQUAL(std::strcmp(serial, serialWithCheckDigit), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NN_TEST_DEFINE_MAIN(UtilTest)
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*
|
||||||
|
End of file
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
Loading…
Reference in New Issue
Block a user