@@ -108,4 +108,27 @@ void test_querying_planets () {
108
108
assert_equal (testOb -> query_planet ("Terra" )["name" ], "Terra" ),
109
109
assert_equal (testOb -> query_planet_size ("Terra" ), 500 ),
110
110
}) :));
111
+ }
112
+
113
+ void test_creating_and_adjusting_planet () {
114
+ string testPlanet = "test_" + time ();
115
+
116
+ expect ("create_planet behaves" , (: ({
117
+ // planet doesn't exist yet
118
+ assert_equal (testOb -> query_planet ($ (testPlanet )), ( [ ]) ),
119
+ // create test planet
120
+ assert_equal (testOb -> create_planet ($ (testPlanet ), ([ "size" : 123 ])), 1 ),
121
+ // planet exists
122
+ assert_equal (testOb -> query_planet ($ (testPlanet )), ([ "name" : $ (testPlanet ), "size" : 123 ])),
123
+ // planet was already created
124
+ assert_equal (testOb -> create_planet ($ (testPlanet ), ( [ ]) ), 0 ),
125
+ }) :));
126
+ expect ("adjust_planet behaves" , (: ({
127
+ // adjust planet size
128
+ assert_equal (testOb -> adjust_planet ($ (testPlanet ), ([ "size" : 321 ])), 1 ),
129
+ // can't adjust non-existant planet
130
+ assert_equal (testOb -> adjust_planet ($ (testPlanet + "-bad" ), ([ "size" : 321 ])), 0 ),
131
+ }) :));
132
+
133
+ rm ("/save/planet/t/" + testPlanet + ".o" );
111
134
}
0 commit comments