commit 545f19c922990eeddcdaaee3bbaf9f8be9fbd3bc Author: iwakeh iwakeh@torproject.org Date: Wed Nov 16 15:02:00 2016 +0100
Part of task-19259 implementation. Added test for accomodating old-style documents, i.e. those using -1.00000000 for missing values. --- .../torproject/onionoo/docs/WeightsStatusTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/src/test/java/org/torproject/onionoo/docs/WeightsStatusTest.java b/src/test/java/org/torproject/onionoo/docs/WeightsStatusTest.java index 501cceb..3dc82f8 100644 --- a/src/test/java/org/torproject/onionoo/docs/WeightsStatusTest.java +++ b/src/test/java/org/torproject/onionoo/docs/WeightsStatusTest.java @@ -217,5 +217,43 @@ public class WeightsStatusTest { } }
+ private static final String[] oldStyle = new String[]{ + "2015-06-01 00:00:00 2015-06-01 12:00:00 0.000883231558 " + + "-1.000000000000 -1.000000000000 -1.000000000000 30500.000000000000\n", + "2015-05-31 13:00:00 2015-05-31 16:00:00 0.000023372492 " + + "-1.000000000000 -1.000000000000 -1.000000000000 778.000000000000\n", + "2014-07-04 22:00:00 2014-07-04 23:00:00 -1.000000000000 " + + "0.000140201280 0.000025070287 0.000025063393 0.000370501851 " + + "-1.000000000000 3210.000000000000\n", + "2014-07-08 19:00:00 2014-07-08 20:00:00 -1.000000000000 0.000000285817" + + " 0.000000000000 0.000000857371 0.000000000000 -1.000000000000 " + + "6.000000000000\n", + "2013-09-29 07:00:00 2013-09-29 08:00:00 -1.000000000000 0.000000844333 " + + "0.000000000000 0.000002532788 0.000000000000 -1.000000000000 " + + "11.000000000000\n" + }; + + private static final String[] newStyle = new String[]{ + "2015-06-01 00:00:00 2015-06-01 12:00:00 0.000883231558 " + + " 30500.000000000000\n", + "2015-05-31 13:00:00 2015-05-31 16:00:00 0.000023372492 " + + " 778.000000000000\n", + "2014-07-04 22:00:00 2014-07-04 23:00:00 0.000140201280 " + + "0.000025070287 0.000025063393 0.000370501851 3210.000000000000\n", + "2014-07-08 19:00:00 2014-07-08 20:00:00 0.000000285817" + + " 0.000000000000 0.000000857371 0.000000000000 6.000000000000\n", + "2013-09-29 07:00:00 2013-09-29 08:00:00 0.000000844333 " + + "0.000000000000 0.000002532788 0.000000000000 11.000000000000\n" + }; + + @Test() + public void testOlderFormat() { + for (int i = 0; i < newStyle.length; i++) { + WeightsStatus ws = new WeightsStatus(); + ws.setFromDocumentString(oldStyle[i]); + assertEquals("Expected\n" + newStyle[i] + "\nbut received\n" + + ws.toDocumentString(), newStyle[i], ws.toDocumentString()); + } + } }
tor-commits@lists.torproject.org