Page MenuHomeCode

No OneTemporary

diff --git a/content/travel.dat b/content/travel.dat
new file mode 100644
index 0000000..2d89507
--- /dev/null
+++ b/content/travel.dat
@@ -0,0 +1,26 @@
+#
+# The [Places] section lists allowed global travel moves.
+# FrL = Can the perso moves freely locally?
+#
+
+[Places]
+#Place FrL Other reachable places
+B00001001 1 B0001002,B0001003
+B00001002 0 B0001001,B0001003
+B00001003 0 B0001001,B0001002
+B00002001 0
+B00003001 0
+
+#
+# Now we add some local travel exceptions
+# = denotes an alias
+#
+[B00001002]
+=C1 "Secteur C1" (-10, 6, -4)
+=C2 "Secteur C2" (10, 6, -4)
+=C3 "Secteur C3" (-10, -6, -4)
+=C4 "Secteur C4" (10, -6, -4)
+=C5 "Secteur C5" (-10, 6, 4)
+=C6 "Secteur C6" (10, 6, 4)
+=C7 "Secteur C7" (-10, -6, 4)
+=C8 "Secteur C8" (10, -6, 4)
\ No newline at end of file
diff --git a/dev/tests/GeoPlaceTest.php b/dev/tests/GeoPlaceTest.php
index 81eef28..d1d8e13 100644
--- a/dev/tests/GeoPlaceTest.php
+++ b/dev/tests/GeoPlaceTest.php
@@ -1,37 +1,51 @@
<?php
require_once('PHPUnit/Framework.php');
require_once('../../includes/geo/place.php');
class GeoPlaceTest extends PHPUnit_Framework_TestCase {
public function testIsValidLocation () {
//Testing HyperShip Tower T2C3 format
$p0 = new GeoPlace();
$p0->location_local_format = '/^T[1-9][0-9]*C[1-6]$/';
$this->assertTrue($p0->is_valid_local_location("T1C1")); // 1
$this->assertTrue($p0->is_valid_local_location("T14C1")); // 2
$this->assertTrue($p0->is_valid_local_location("T14C6")); // 3
$this->assertTrue($p0->is_valid_local_location("T140C6")); // 4
$this->assertTrue($p0->is_valid_local_location("T14000C6")); // 5
$this->assertFalse($p0->is_valid_local_location("C1T6")); // 6
$this->assertFalse($p0->is_valid_local_location("T14000 C6")); // 7
$this->assertFalse($p0->is_valid_local_location("T4C7")); // 8
$this->assertFalse($p0->is_valid_local_location("T4C0")); // 9
$this->assertFalse($p0->is_valid_local_location("T0C0")); //10
//Unit testing is useful: this test led to fix the regexp
//from T[0-9]+C[1-6] to T[1-9][0-9]*C[1-6]
$this->assertFalse($p0->is_valid_local_location("T0C1")); //11
//Testing default format
$p1 = new GeoPlace();
-
+
$this->assertTrue($p1->is_valid_local_location("(4,62,35)")); //12
$this->assertTrue($p1->is_valid_local_location("(4, 62, 35)")); //13
$this->assertTrue($p1->is_valid_local_location("(4, 62,35)")); //14
$this->assertFalse($p1->is_valid_local_location("(4,62,-35)")); //15
$this->assertFalse($p1->is_valid_local_location("(4, 62)")); //16
+
+
+ //Testing (x, y, -z) format
+ $p2 = new GeoPlace();
+ $p2->location_local_format = '/^\(\-?[0-9]+( )*,( )*\-?[0-9]+( )*,( )*\-?[0-9]+\)$/';
+
+ $this->assertTrue($p2->is_valid_local_location("(4,62,35)")); //17
+ $this->assertTrue($p2->is_valid_local_location("(4, 62, 35)")); //18
+ $this->assertTrue($p2->is_valid_local_location("(4, 62,35)")); //19
+ $this->assertTrue($p2->is_valid_local_location("(4,62,-35)")); //20
+
+ $this->assertFalse($p2->is_valid_local_location("(4,62,- 35)")); //21
+ $this->assertFalse($p2->is_valid_local_location("(4,62, - 35)")); //22
+ $this->assertFalse($p2->is_valid_local_location("(4, 62)")); //23
}
}
-?>
\ No newline at end of file
+?>

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 4, 00:32 (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21266
Default Alt Text
(3 KB)

Event Timeline