]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/testdata.cpp
1 /********************************************************************
3 * Copyright (c) 2002-2005, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 /* Created by weiv 05/09/2002 */
9 #include "unicode/testdata.h"
12 TestData::TestData(const char* testName
)
25 TestData::~TestData() {
29 if(fCurrSettings
!= NULL
) {
32 if(fCurrCase
!= NULL
) {
37 const char * TestData::getName() const
44 RBTestData::RBTestData(const char* testName
)
53 RBTestData::RBTestData(UResourceBundle
*data
, UResourceBundle
*headers
, UErrorCode
& status
)
54 : TestData(ures_getKey(data
)),
60 UErrorCode intStatus
= U_ZERO_ERROR
;
61 UResourceBundle
*currHeaders
= ures_getByKey(data
, "Headers", NULL
, &intStatus
);
62 if(intStatus
== U_ZERO_ERROR
) {
64 fHeaders
= currHeaders
;
66 intStatus
= U_ZERO_ERROR
;
68 fSettings
= ures_getByKey(data
, "Settings", NULL
, &intStatus
);
69 fSettingsSize
= ures_getSize(fSettings
);
70 UResourceBundle
*info
= ures_getByKey(data
, "Info", NULL
, &intStatus
);
71 if(U_SUCCESS(intStatus
)) {
72 fInfo
= new RBDataMap(info
, status
);
74 intStatus
= U_ZERO_ERROR
;
76 fCases
= ures_getByKey(data
, "Cases", NULL
, &status
);
77 fCasesSize
= ures_getSize(fCases
);
83 RBTestData::~RBTestData()
87 ures_close(fSettings
);
91 UBool
RBTestData::getInfo(const DataMap
*& info
, UErrorCode
&/*status*/) const
102 UBool
RBTestData::nextSettings(const DataMap
*& settings
, UErrorCode
&status
)
104 UErrorCode intStatus
= U_ZERO_ERROR
;
105 UResourceBundle
*data
= ures_getByIndex(fSettings
, fCurrentSettings
++, NULL
, &intStatus
);
106 if(U_SUCCESS(intStatus
)) {
107 // reset the cases iterator
109 if(fCurrSettings
== NULL
) {
110 fCurrSettings
= new RBDataMap(data
, status
);
112 ((RBDataMap
*)fCurrSettings
)->init(data
, status
);
115 settings
= fCurrSettings
;
123 UBool
RBTestData::nextCase(const DataMap
*& nextCase
, UErrorCode
&status
)
125 UErrorCode intStatus
= U_ZERO_ERROR
;
126 UResourceBundle
*currCase
= ures_getByIndex(fCases
, fCurrentCase
++, NULL
, &intStatus
);
127 if(U_SUCCESS(intStatus
)) {
128 if(fCurrCase
== NULL
) {
129 fCurrCase
= new RBDataMap(fHeaders
, currCase
, status
);
131 ((RBDataMap
*)fCurrCase
)->init(fHeaders
, currCase
, status
);
133 ures_close(currCase
);
134 nextCase
= fCurrCase
;