From 850bb72f3798d909cf2abfd35327f5b70fb9849c Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 25 Nov 2021 00:32:52 +0100 Subject: [PATCH] Remove nanosecond datetime tests, document implementation-defined behaviour I considered copying this to a special "optional" directory or something, but it gets very complicated very fast with different permutations. There's no telling what precision an implementation supports. So just document it. It makes things easier for everyone. Fixes #91 --- README.md | 13 +++++++++++++ tests/valid/datetime/milliseconds.json | 8 ++++---- tests/valid/datetime/milliseconds.toml | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5da06f7..398b1c9 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,19 @@ An example implementation can be found in the BurnSushi/toml: - [Add tags](https://github.com/BurntSushi/toml/blob/master/internal/tag/add.go) - [Remove tags](https://github.com/BurntSushi/toml/blob/master/internal/tag/rm.go) +Implementation-defined behaviour +-------------------------------- +This only tests behaviour that's should be true for every encoder implementing +TOML; a few things are left up to implementations, and are not tested here. + +- Millisecond precision (4 digits) is required for datetimes and times, and + further precision is implementation-specific, and any greater precision than + is supported must be truncated (not rounded). + + This tests only millisecond precision, and not any further precision or the + truncation of it. + + Assumptions of Truth -------------------- The following are taken as ground truths by `toml-test`: diff --git a/tests/valid/datetime/milliseconds.json b/tests/valid/datetime/milliseconds.json index bb896af..c49e400 100644 --- a/tests/valid/datetime/milliseconds.json +++ b/tests/valid/datetime/milliseconds.json @@ -1,18 +1,18 @@ { "utc1": { "type": "datetime", - "value": "1987-07-05T17:45:56.123456Z" + "value": "1987-07-05T17:45:56.1234Z" }, "utc2": { "type": "datetime", - "value": "1987-07-05T17:45:56.600000Z" + "value": "1987-07-05T17:45:56.6000Z" }, "wita1": { "type": "datetime", - "value": "1987-07-05T17:45:56.123456+08:00" + "value": "1987-07-05T17:45:56.1234+08:00" }, "wita2": { "type": "datetime", - "value": "1987-07-05T17:45:56.600000+08:00" + "value": "1987-07-05T17:45:56.6000+08:00" } } diff --git a/tests/valid/datetime/milliseconds.toml b/tests/valid/datetime/milliseconds.toml index a6c0590..24b81f8 100644 --- a/tests/valid/datetime/milliseconds.toml +++ b/tests/valid/datetime/milliseconds.toml @@ -1,4 +1,4 @@ -utc1 = 1987-07-05T17:45:56.123456Z +utc1 = 1987-07-05T17:45:56.1234Z utc2 = 1987-07-05T17:45:56.6Z -wita1 = 1987-07-05T17:45:56.123456+08:00 +wita1 = 1987-07-05T17:45:56.1234+08:00 wita2 = 1987-07-05T17:45:56.6+08:00