• R/O
  • SSH
  • HTTPS

cadencii: コミット


コミットメタ情報

リビジョン1966 (tree)
日時2012-01-15 03:56:38
作者kbinani

ログメッセージ

[vConnect/trunk/stand2.0] added: UtauDBのテストを追加

変更サマリ

差分

--- vConnect/trunk/stand2.0/stand/tests/fixture/utau/UtauDB/oto.ini (nonexistent)
+++ vConnect/trunk/stand2.0/stand/tests/fixture/utau/UtauDB/oto.ini (revision 1966)
@@ -0,0 +1,2 @@
1+_ああいあうえあ.wav=a あ,500.0,400,-500,250.0,83.333
2+あ.wav=,500.0,400,-500,250.0,83.333
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- vConnect/trunk/stand2.0/stand/tests/MapTest.cpp (revision 1965)
+++ vConnect/trunk/stand2.0/stand/tests/MapTest.cpp (revision 1966)
@@ -3,6 +3,7 @@
33 #include "AllTests.h"
44 #include "../Map.h"
55
6+using namespace std;
67 using namespace vconnect;
78
89 class MapTest : public CppUnit::TestFixture {
--- vConnect/trunk/stand2.0/stand/tests/UtauParameterTest.cpp (revision 1965)
+++ vConnect/trunk/stand2.0/stand/tests/UtauParameterTest.cpp (revision 1966)
@@ -1,5 +1,5 @@
11 #include "AllTests.h"
2-#include "../utauVoiceDB/UtauParameter.h"
2+#include "../utau/UtauParameter.h"
33
44 using namespace vconnect;
55 using namespace std;
--- vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1965)
+++ vConnect/trunk/stand2.0/stand/tests/Makefile (revision 1966)
@@ -1,3 +1,6 @@
1+SOURCE=./*.cpp ./*/*.cpp \
2+ ../Thread.cpp ../Mutex.cpp ../vsqMetaText/Lyric.cpp \
3+ ../utau/UtauDB.cpp
14 all: *.cpp *.h
2- g++ -finput-charset=UTF-8 *.cpp ../Thread.cpp ../Mutex.cpp ../vsqMetaText/Lyric.cpp ../../libiconv-1.13/lib/*.o -lcppunit -o run
5+ g++ -finput-charset=UTF-8 $(SOURCE) ../../libiconv-1.13/lib/*.o -lcppunit -o run
36 ./run
--- vConnect/trunk/stand2.0/stand/tests/utau/UtauDBTest.cpp (nonexistent)
+++ vConnect/trunk/stand2.0/stand/tests/utau/UtauDBTest.cpp (revision 1966)
@@ -0,0 +1,73 @@
1+#ifndef TEST_UtauDBTest
2+#define TEST_UtauDBTest
3+#include "../AllTests.h"
4+#include "../../utau/UtauDB.h"
5+#include "../../Path.h"
6+
7+using namespace std;
8+using namespace vconnect;
9+
10+class UtauDBTest : public CppUnit::TestFixture
11+{
12+public:
13+ void testConstruct()
14+ {
15+ string path = Path::getFullPath( "fixture/utau/UtauDB/oto.ini" );
16+ UtauDB db( path, "Shift_JIS" );
17+ string expectedPath = Path::getDirectoryName( path ) + Path::getDirectorySeparator();
18+ CPPUNIT_ASSERT_EQUAL( expectedPath, db.getOtoIniPath() );
19+
20+ UtauParameter resultByLyric;
21+ int ret = db.getParams( resultByLyric, "a あ" );
22+ CPPUNIT_ASSERT_EQUAL( 1, ret );
23+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), resultByLyric.fileName );
24+
25+ UtauParameter resultByFileName;
26+ ret = db.getParams( resultByFileName, "_ああいあうえあ" );
27+ CPPUNIT_ASSERT_EQUAL( 1, ret );
28+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), resultByFileName.fileName );
29+
30+ ret = db.getParams( resultByFileName, "音源に存在しない歌詞を指定" );
31+ CPPUNIT_ASSERT_EQUAL( 0, ret );
32+
33+ // イテレータによるアクセス
34+ // イテレータによるアクセスでは、エイリアスで登録したものについてもアクセスされる
35+ Map<string, UtauParameter *>::iterator i;
36+ int count = 0;
37+ for( i = db.begin(); i != db.end(); i++ ){
38+ count++;
39+ }
40+ CPPUNIT_ASSERT_EQUAL( 3, count );
41+
42+ Map<string, UtauParameter *>::iterator j = db.begin();
43+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), j->first );
44+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), j->second->fileName );
45+ j++;
46+ CPPUNIT_ASSERT_EQUAL( string( "a あ" ), j->first );
47+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), j->second->fileName );
48+ j++;
49+ CPPUNIT_ASSERT_EQUAL( string( "あ" ), j->first );
50+ CPPUNIT_ASSERT_EQUAL( string( "あ" ), j->second->fileName );
51+ j++;
52+ CPPUNIT_ASSERT( j == db.end() );
53+
54+ // インデックスによるアクセス
55+ // インデックスによるアクセスでは、エイリアスで登録したものについてはアクセスされない
56+ CPPUNIT_ASSERT_EQUAL( 2, db.size() );
57+ UtauParameter result;
58+ ret = db.getParams( result, 0 );
59+ CPPUNIT_ASSERT_EQUAL( 1, ret );
60+ CPPUNIT_ASSERT_EQUAL( string( "_ああいあうえあ" ), result.fileName );
61+ ret = db.getParams( result, 1 );
62+ CPPUNIT_ASSERT_EQUAL( string( "あ" ), result.fileName );
63+
64+ ret = db.getParams( result, -1 );
65+ CPPUNIT_ASSERT_EQUAL( 0, ret );
66+ }
67+
68+ CPPUNIT_TEST_SUITE( UtauDBTest );
69+ CPPUNIT_TEST( testConstruct );
70+ CPPUNIT_TEST_SUITE_END();
71+};
72+REGISTER_TEST_SUITE( UtauDBTest );
73+#endif
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- vConnect/trunk/stand2.0/stand/utau/UtauDB.cpp (revision 1965)
+++ vConnect/trunk/stand2.0/stand/utau/UtauDB.cpp (revision 1966)
@@ -51,10 +51,13 @@
5151 return;
5252 }
5353
54- mDBPath = path_oto_ini.substr( 0, path_oto_ini.rfind( Path::getDirectorySeparator() ) + 1 );
54+ mDBPath = Path::combine( Path::getDirectoryName( path_oto_ini ), "" );
5555
5656 while( stream.ready() ){
5757 string line = stream.readLine();
58+ if( line.length() == 0 ){
59+ continue;
60+ }
5861 UtauParameter *current = new UtauParameter( line );
5962 mSettingMap.insert( make_pair( current->lyric, current ) );
6063 if( current->lyric.compare( current->fileName ) != 0 ){
旧リポジトリブラウザで表示