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