]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/testdata.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 2002-2005, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 /* Created by weiv 05/09/2002 */
11 #include "unicode/testdata.h"
14 TestData::TestData(const char* testName
)
27 TestData::~TestData() {
31 if(fCurrSettings
!= NULL
) {
34 if(fCurrCase
!= NULL
) {
39 const char * TestData::getName() const
46 RBTestData::RBTestData(const char* testName
)
55 RBTestData::RBTestData(UResourceBundle
*data
, UResourceBundle
*headers
, UErrorCode
& status
)
56 : TestData(ures_getKey(data
)),
62 UErrorCode intStatus
= U_ZERO_ERROR
;
63 UResourceBundle
*currHeaders
= ures_getByKey(data
, "Headers", NULL
, &intStatus
);
64 if(intStatus
== U_ZERO_ERROR
) {
66 fHeaders
= currHeaders
;
68 intStatus
= U_ZERO_ERROR
;
70 fSettings
= ures_getByKey(data
, "Settings", NULL
, &intStatus
);
71 fSettingsSize
= ures_getSize(fSettings
);
72 UResourceBundle
*info
= ures_getByKey(data
, "Info", NULL
, &intStatus
);
73 if(U_SUCCESS(intStatus
)) {
74 fInfo
= new RBDataMap(info
, status
);
76 intStatus
= U_ZERO_ERROR
;
78 fCases
= ures_getByKey(data
, "Cases", NULL
, &status
);
79 fCasesSize
= ures_getSize(fCases
);
85 RBTestData::~RBTestData()
89 ures_close(fSettings
);
93 UBool
RBTestData::getInfo(const DataMap
*& info
, UErrorCode
&/*status*/) const
104 UBool
RBTestData::nextSettings(const DataMap
*& settings
, UErrorCode
&status
)
106 UErrorCode intStatus
= U_ZERO_ERROR
;
107 UResourceBundle
*data
= ures_getByIndex(fSettings
, fCurrentSettings
++, NULL
, &intStatus
);
108 if(U_SUCCESS(intStatus
)) {
109 // reset the cases iterator
111 if(fCurrSettings
== NULL
) {
112 fCurrSettings
= new RBDataMap(data
, status
);
114 ((RBDataMap
*)fCurrSettings
)->init(data
, status
);
117 settings
= fCurrSettings
;
125 UBool
RBTestData::nextCase(const DataMap
*& nextCase
, UErrorCode
&status
)
127 UErrorCode intStatus
= U_ZERO_ERROR
;
128 UResourceBundle
*currCase
= ures_getByIndex(fCases
, fCurrentCase
++, NULL
, &intStatus
);
129 if(U_SUCCESS(intStatus
)) {
130 if(fCurrCase
== NULL
) {
131 fCurrCase
= new RBDataMap(fHeaders
, currCase
, status
);
133 ((RBDataMap
*)fCurrCase
)->init(fHeaders
, currCase
, status
);
135 ures_close(currCase
);
136 nextCase
= fCurrCase
;