| 139 | } |
| 140 | |
| 141 | void testNullData() |
| 142 | { |
| 143 | CompoundObjectPtr d = new CompoundObject(); |
| 144 | d->members()["floatElement"] = new FloatData( 42.0f ); |
| 145 | d->members()["stringElement"] = new StringData( "cake" ); |
| 146 | |
| 147 | // sanity check first. |
| 148 | try |
| 149 | { |
| 150 | CompoundObjectPtr dd = d->copy(); |
| 151 | } |
| 152 | catch ( std::exception & ) |
| 153 | { |
| 154 | BOOST_CHECK( !"Exception thrown during CompoundObject copy." ); |
| 155 | } |
| 156 | |
| 157 | CompoundObjectPtr c = new CompoundObject(); |
| 158 | c->members()["nullElement"] = 0; |
| 159 | |
| 160 | // copy |
| 161 | try |
| 162 | { |
| 163 | CompoundObjectPtr cCopy = c->copy(); |
| 164 | |
| 165 | BOOST_CHECK( !"Exception not thrown during copy with invalid NULL data." ); |
| 166 | } |
| 167 | catch ( std::exception & ) |
| 168 | { |
| 169 | } |
| 170 | |
| 171 | // save |
| 172 | try |
| 173 | { |
| 174 | IndexedIOPtr io = new MemoryIndexedIO( NULL, IndexedIO::rootPath, IndexedIO::Write); |
| 175 | IndexedIO::EntryID entryName( "test" ); |
| 176 | c->Object::save( io, entryName ); |
| 177 | |
| 178 | BOOST_CHECK( !"Exception not thrown during save with invalid NULL data." ); |
| 179 | } |
| 180 | catch ( std::exception & ) |
| 181 | { |
| 182 | } |
| 183 | |
| 184 | // memoryUsage |
| 185 | try |
| 186 | { |
| 187 | c->Object::memoryUsage(); |
| 188 | } |
| 189 | catch ( std::exception & ) |
| 190 | { |
| 191 | BOOST_CHECK( !"Exception thrown during memoryCopy with invalid NULL data." ); |
| 192 | } |
| 193 | |
| 194 | // isEqual |
| 195 | try |
| 196 | { |
| 197 | CompoundObjectPtr c2 = new CompoundObject(); |
| 198 | c2->members()["nullElement"] = 0; |