KenKundert / nestedtext_tests

5 stars 2 forks source link

Official NestedText Test Suite

Version: 3.7

Test cases for NestedText are written in JSON, for the purpose of allowing NestedText implementations in any language to use the same tests.

Understanding the tests

Each test case consists of a directory with some number of the following files:

It's very possible for a single test case to test both the load() and dump() functions. For such tests, it's common to symlink load_in.nt to dump_out.nt and/or load_out.json to dump_in.json.

Using the tests

Installation

This repository is meant to be included as a submodule of any repository that implements the NestedText standard. This approach makes it easy to share tests between implementations (e.g. corner cases found in one implementation could be added to this repository and made available to every implementation) and easy to control which version of the tests are being used (e.g. ).

It would be good to familiarize yourself with the git submodule command before attempting to incorporate these tests into a project, but the basic command to do so is shown below. Note that it's conventional to name the submodule official_tests:

$ git init «new-project»
$ cd «new-project»
$ git submodule add git@github.com:KenKundert/nestedtext_tests.git tests/official_tests

To incorporate new tests from the upstream repository:

$ cd tests/official_tests
$ git pull

APIs

The api/ directory contains code that parses the test cases into native data structures for different languages. If you're writing an implementation for a language that isn't represented in the api/ directory yet, it would be much appreciated if you could submit an API (via pull request) and make it easier for others to create implementations.

There are also APIs maintained outside of this source tree:

Helper scripts

In addition to the tests themselves, this repository contains a number of helper scripts to make it easier to work with the tests. These scripts include:

For more detailed usage information, run any of these scripts with the -h flag.