/** * Check if saving and loading of StringArray's works * Also checks that save is nondestructive */ function putSaveGetSavedTestCase() { $this->test_objects['FILE1']->put(0, pack("N", 5)); $this->test_objects['FILE1']->put(1, pack("N", 4)); $this->test_objects['FILE1']->put(2, pack("N", 3)); $this->test_objects['FILE1']->put(3, pack("N", 2)); $this->test_objects['FILE1']->save(); $object = StringArray::load(WORK_DIRECTORY . "/array.txt"); //check can read in what we saved $tmp = unpack("N", $object->get(0)); $this->assertEqual($tmp[1], 5, "Get put 0th items equal"); $tmp = unpack("N", $object->get(1)); $this->assertEqual($tmp[1], 4, "Get put 1th items equal"); $tmp = unpack("N", $object->get(2)); $this->assertEqual($tmp[1], 3, "Get put 2th items equal"); $tmp = unpack("N", $object->get(3)); $this->assertEqual($tmp[1], 2, "Get put 3th items equal"); // check that writing didn't mess-up original object $tmp = unpack("N", $this->test_objects['FILE1']->get(0)); $this->assertEqual($tmp[1], 5, "Get put 0th items equal"); $tmp = unpack("N", $this->test_objects['FILE1']->get(1)); $this->assertEqual($tmp[1], 4, "Get put 1th items equal"); $tmp = unpack("N", $this->test_objects['FILE1']->get(2)); $this->assertEqual($tmp[1], 3, "Get put 2th items equal"); $tmp = unpack("N", $this->test_objects['FILE1']->get(3)); $this->assertEqual($tmp[1], 2, "Get put 3th items equal"); }