[openssh-commits] [openssh] 01/02: upstream: Unit test for convtime. ok djm@
git+noreply at mindrot.org
git+noreply at mindrot.org
Fri May 29 15:48:29 AEST 2020
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 0b15892fc47d6840eba1291a6be9be1a70bc8972
Author: dtucker at openbsd.org <dtucker at openbsd.org>
Date: Fri May 29 01:21:35 2020 +0000
upstream: Unit test for convtime. ok djm@
OpenBSD-Regress-ID: cec4239efa2fc4c7062064f07a847e1cbdbcd5dd
---
regress/unittests/misc/tests.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/regress/unittests/misc/tests.c b/regress/unittests/misc/tests.c
index ed775ebb..8fe6aedb 100644
--- a/regress/unittests/misc/tests.c
+++ b/regress/unittests/misc/tests.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tests.c,v 1.1 2019/04/28 22:53:26 dtucker Exp $ */
+/* $OpenBSD: tests.c,v 1.2 2020/05/29 01:21:35 dtucker Exp $ */
/*
* Regress test for misc helper functions.
*
@@ -76,4 +76,23 @@ tests(void)
ASSERT_STRING_EQ(path, "some/path");
free(user); free(host); free(path);
TEST_DONE();
+
+ TEST_START("misc_convtime");
+ ASSERT_LONG_EQ(convtime("1"), 1);
+ ASSERT_LONG_EQ(convtime("2s"), 2);
+ ASSERT_LONG_EQ(convtime("3m"), 180);
+ ASSERT_LONG_EQ(convtime("1m30"), 90);
+ ASSERT_LONG_EQ(convtime("1m30s"), 90);
+ ASSERT_LONG_EQ(convtime("1h1s"), 3601);
+ ASSERT_LONG_EQ(convtime("1h30m"), 90 * 60);
+ ASSERT_LONG_EQ(convtime("1d"), 24 * 60 * 60);
+ ASSERT_LONG_EQ(convtime("1w"), 7 * 24 * 60 * 60);
+ ASSERT_LONG_EQ(convtime("1w2d3h4m5"), 788645);
+ ASSERT_LONG_EQ(convtime("1w2d3h4m5s"), 788645);
+ /* any negative number or error returns -1 */
+ ASSERT_LONG_EQ(convtime("-1"), -1);
+ ASSERT_LONG_EQ(convtime(""), -1);
+ ASSERT_LONG_EQ(convtime("trout"), -1);
+ ASSERT_LONG_EQ(convtime("-77"), -1);
+ TEST_DONE();
}
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list