27 using namespace pwiz::util;
36 template<
typename T>
bool equals(
const T& lhs,
const T& rhs) {
return lhs == rhs;}
37 template<>
bool equals(
const BSTR& lhs,
const BSTR& rhs) {
return !strcmp((
const char*)lhs, (
const char*)rhs);}
39 template<
typename T> T&
assign(T& lhs,
const T& rhs) {
return lhs = rhs;}
40 template<> BSTR&
assign(BSTR& lhs,
const BSTR& rhs) {lhs = ::SysAllocString((
const OLECHAR*)rhs);
return lhs;}
46 typedef automation_vector<T> TestVector;
47 T testValue(defaultValue<T>());
63 v.resize(1000000, testValue);
74 for (
size_t i=0; i < v.size(); ++i)
86 TestVector v(10, testValue);
94 for (
size_t i=0; i < v.size(); ++i)
100 for (TestVector::iterator itr = v.begin(); itr != v.end(); ++itr)
103 for (TestVector::const_iterator itr = v.begin(); itr != v.end(); ++itr)
106 for (TestVector::reverse_iterator itr = v.rbegin(); itr != v.rend(); ++itr)
109 for (TestVector::const_reverse_iterator itr = v.rbegin(); itr != v.rend(); ++itr)
115 ::VariantInit(&variant);
117 TestVector v(10, testValue);
123 unit_assert(variant.parray->rgsabound->cElements == 10);
125 TestVector v2(variant, TestVector::COPY);
129 unit_assert(variant.parray->rgsabound->cElements == 10);
130 for (
size_t i=0; i < v2.size(); ++i)
135 TestVector v(variant, TestVector::MOVE);
137 for (
size_t i=0; i < v.size(); ++i)
139 ::VariantClear(&variant);
143 TestVector v2(variant, TestVector::COPY);
144 for (
size_t i=0; i < v2.size(); ++i)
151 ::VariantClear(&variant);
153 for (
size_t i=0; i < v.size(); ++i)
158 TestVector v2(variant, TestVector::COPY);
159 for (
size_t i=0; i < v2.size(); ++i)
165 int main(
int argc,
char* argv[])
171 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
172 if (
os_) *
os_ <<
"automation_vector_test\n";
173 testInterface<BSTR>();
174 testInterface<signed char>();
175 testInterface<signed short>();
176 testInterface<signed int>();
177 testInterface<signed long>();
178 testInterface<unsigned char>();
179 testInterface<unsigned short>();
180 testInterface<unsigned int>();
181 testInterface<unsigned long>();
182 testInterface<float>();
183 testInterface<double>();