]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/testdata.cpp
1 /********************************************************************
3 * Copyright (c) 2002-2004, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 /* Created by weiv 05/09/2002 */
9 #include "unicode/testdata.h"
11 TestData::TestData(const char* name
)
24 TestData::~TestData() {
28 if(fCurrSettings
!= NULL
) {
31 if(fCurrCase
!= NULL
) {
36 const char * TestData::getName() const
43 RBTestData::RBTestData(const char* name
)
52 RBTestData::RBTestData(UResourceBundle
*data
, UResourceBundle
*headers
, UErrorCode
& status
)
53 : TestData(ures_getKey(data
)),
59 UErrorCode intStatus
= U_ZERO_ERROR
;
60 UResourceBundle
*currHeaders
= ures_getByKey(data
, "Headers", NULL
, &intStatus
);
61 if(intStatus
== U_ZERO_ERROR
) {
63 fHeaders
= currHeaders
;
65 intStatus
= U_ZERO_ERROR
;
67 fSettings
= ures_getByKey(data
, "Settings", NULL
, &intStatus
);
68 fSettingsSize
= ures_getSize(fSettings
);
69 UResourceBundle
*info
= ures_getByKey(data
, "Info", NULL
, &intStatus
);
70 if(U_SUCCESS(intStatus
)) {
71 fInfo
= new RBDataMap(info
, status
);
73 intStatus
= U_ZERO_ERROR
;
75 fCases
= ures_getByKey(data
, "Cases", NULL
, &status
);
76 fCasesSize
= ures_getSize(fCases
);
82 RBTestData::~RBTestData()
86 ures_close(fSettings
);
90 UBool
RBTestData::getInfo(const DataMap
*& info
, UErrorCode
&/*status*/) const
101 UBool
RBTestData::nextSettings(const DataMap
*& settings
, UErrorCode
&status
)
103 UErrorCode intStatus
= U_ZERO_ERROR
;
104 UResourceBundle
*data
= ures_getByIndex(fSettings
, fCurrentSettings
++, NULL
, &intStatus
);
105 if(U_SUCCESS(intStatus
)) {
106 // reset the cases iterator
108 if(fCurrSettings
== NULL
) {
109 fCurrSettings
= new RBDataMap(data
, status
);
111 ((RBDataMap
*)fCurrSettings
)->init(data
, status
);
114 settings
= fCurrSettings
;
122 UBool
RBTestData::nextCase(const DataMap
*& nextCase
, UErrorCode
&status
)
124 UErrorCode intStatus
= U_ZERO_ERROR
;
125 UResourceBundle
*currCase
= ures_getByIndex(fCases
, fCurrentCase
++, NULL
, &intStatus
);
126 if(U_SUCCESS(intStatus
)) {
127 if(fCurrCase
== NULL
) {
128 fCurrCase
= new RBDataMap(fHeaders
, currCase
, status
);
130 ((RBDataMap
*)fCurrCase
)->init(fHeaders
, currCase
, status
);
132 ures_close(currCase
);
133 nextCase
= fCurrCase
;