def test_extend(self): """ Tests the extend function. """ cc = CarrayContainer(var_dict={"tmp": "int"}) self.assertEqual(cc.get_number_of_items(), 0) print "num:", cc.get_number_of_items() cc.extend(100) print "num:", cc.get_number_of_items() self.assertEqual(cc.get_number_of_items(), 100) for field in cc.properties.itervalues(): self.assertEqual(field.length, 100)
def test_constructor_dict(self): """Test the constructor using dict.""" flux_vars = { "mass": "double", "momentum-x": "double", "momentum-y": "double", "energy": "double", } cc = CarrayContainer(var_dict=flux_vars) self.assertEqual(cc.get_number_of_items(), 0) self.assertItemsEqual(cc.properties.keys(), flux_vars.keys()) for field_name in cc.properties.keys(): self.assertEqual(cc[field_name].size, 0)