From faffe70befc326844a46493c9339284c3cb679e2 Mon Sep 17 00:00:00 2001 From: Aaron Huisinga Date: Tue, 16 Feb 2021 17:03:28 -0600 Subject: [PATCH] Add test file for DBase 7 double type --- src/XBase/Record/DBase7Record.php | 8 ++++++++ tests/DBaseTest.php | 14 ++++++++++++++ tests/Resources/dBase/dBaseVII_double.dbf | Bin 0 -> 163 bytes 3 files changed, 22 insertions(+) create mode 100755 tests/Resources/dBase/dBaseVII_double.dbf diff --git a/src/XBase/Record/DBase7Record.php b/src/XBase/Record/DBase7Record.php index ba82423..998a848 100644 --- a/src/XBase/Record/DBase7Record.php +++ b/src/XBase/Record/DBase7Record.php @@ -34,4 +34,12 @@ public function getInt(string $columnName): int { return $this->get($columnName); } + + /** + * @deprecated since 1.3 and will be delete in 2.0. Use get() + */ + public function getDouble(string $columnName): float + { + return $this->get($columnName); + } } diff --git a/tests/DBaseTest.php b/tests/DBaseTest.php index 0dc890a..f54d142 100644 --- a/tests/DBaseTest.php +++ b/tests/DBaseTest.php @@ -383,6 +383,20 @@ public function testDbase7int(): void self::assertSame(2147483647, $table->nextRecord()->getInt('int')); self::assertSame(-2147483647, $table->nextRecord()->getInt('int')); } + + public function testDbase7double(): void + { + $table = new Table(__DIR__.'/Resources/dBase/dBaseVII_double.dbf'); + self::assertSame(1, $table->getColumnCount()); + self::assertSame(5, $table->getRecordCount()); + self::assertSame(TableType::DBASE_7_NOMEMO, $table->getVersion()); + + self::assertSame(-199.99, $table->nextRecord()->getDouble('double')); + self::assertSame(-74.62, $table->nextRecord()->getDouble('double')); + self::assertSame(43.65, $table->nextRecord()->getDouble('double')); + self::assertSame(150.48, $table->nextRecord()->getDouble('double')); + self::assertSame(0.0, $table->nextRecord()->getDouble('double')); + } protected function assertMemoImg(Table $table) { diff --git a/tests/Resources/dBase/dBaseVII_double.dbf b/tests/Resources/dBase/dBaseVII_double.dbf new file mode 100755 index 0000000000000000000000000000000000000000..c08ac41552436a26d4b778594555290e46091c26 GIT binary patch literal 163 zcmZRnWD;OyU|=X^-~^JGz{M%t(=RmG08<7bl9FGVl#`0!qqF=uP(^qZ?58sXzHXJ< fu3*150>U`pdf6BR6b>YvkJ0#gs9&K0s!0j}b+i^x literal 0 HcmV?d00001