Skip to content

Commit

Permalink
Updated readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukezbihlyj committed Feb 13, 2015
1 parent 68909b9 commit 13a4e14
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
7 changes: 6 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# VDF Parser

An open-source VDF parser for Valve's proprietary format used in Source games. This package is 100% tested and available for use in any project under the MIT license.
An open-source VDF parser for Valve's proprietary format used in Source games. This package is 100% tested and available for use in any project under the MIT license. The parser currently supports all features of VDF, including:

- Arbitrary whitespace, including tab characters and spaces.
- Comments, which will be ignored during parsing.
- Escaped strings, allowing backslash escaping inside strings for both keys and values.
- Nested arrays, using recursion.

## Installation

Expand Down
46 changes: 46 additions & 0 deletions test/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,50 @@ public function testParseWorksWithSubArrays()

$this->assertEquals($result, $this->parser->parse($vdf));
}

/**
* @covers ::parse
*/
public function testParseAllowsRandomWhitespace()
{
$vdf = <<<VDF
{
"one" {
"inner" "This is a sub-array element."
}}
VDF;

$result = [
'one' => [
'inner' => 'This is a sub-array element.',
],
];

$this->assertEquals($result, $this->parser->parse($vdf));
}

/**
* @covers ::parse
*/
public function testParseAllowsComments()
{
$vdf = <<<VDF
{
// This is a comment, ignore me.
"one" {
"inner" "This is a sub-array element." // Ignore me also.
// Don't load me. "ignore" "me"
}
}
VDF;

$result = [
'one' => [
'inner' => 'This is a sub-array element.',
],
];

$this->assertEquals($result, $this->parser->parse($vdf));
}
}

0 comments on commit 13a4e14

Please sign in to comment.