[rtems commit] Tests for inttype.h methods

Gedare Bloom gedare at rtems.org
Tue Apr 7 22:17:34 UTC 2020


Module:    rtems
Branch:    master
Commit:    81e25245fcc996ba08d0968856798c50325cd501
Changeset: http://git.rtems.org/rtems/commit/?id=81e25245fcc996ba08d0968856798c50325cd501

Author:    Eshan dhawan <eshandhawan51 at gmail.com>
Date:      Wed Apr  8 02:14:40 2020 +0530

Tests for inttype.h methods

---

 testsuites/psxtests/psxinttypes01/init.c           | 24 +++++++++++++++++++++-
 .../psxtests/psxinttypes01/psxinttypes01.doc       | 10 ++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/testsuites/psxtests/psxinttypes01/init.c b/testsuites/psxtests/psxinttypes01/init.c
index 030aa2a..615b9d9 100644
--- a/testsuites/psxtests/psxinttypes01/init.c
+++ b/testsuites/psxtests/psxinttypes01/init.c
@@ -6,6 +6,7 @@
 /*
  * SPDX-License-Identifier: BSD-2-Clause
  *
+ * Copyright (C) 2020, Eshan Dhawan
  * Copyright (C) 2019, Aditya Upadhyay and Vaibhav Gupta
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,11 +65,32 @@ rtems_task Init(rtems_task_argument ignored)
   wchar_t  *nptr2_n_errange = L"-9999999999999999999999";
   wchar_t  *endptr2         = NULL;
 
-  intmax_t  result_strtoimax;
+  intmax_t  result_strtoimax, result_imaxabs, input_1, input_2;
+  imaxdiv_t result_exp, result_imaxdiv;
   uintmax_t result_strtoumax;
 
   TEST_BEGIN();
 
+  /* Test for imaxabs */
+  input_1 = -10;
+  result_imaxabs = 10;
+  rtems_test_assert( imaxabs(input_1) == result_imaxabs );
+
+  input_1 = 10;
+  result_imaxabs = 10;
+  rtems_test_assert( imaxabs(input_1) == result_imaxabs );
+
+  /* Test for imaxdiv */
+  input_1 = 10;
+  input_2 = 3;
+  result_exp.quot = input_1 / input_2;
+  result_exp.rem =  input_1 % input_2;
+  result_imaxdiv = imaxdiv( input_1, input_2 );
+  rtems_test_assert(
+    result_imaxdiv.quot == result_exp.quot &&
+    result_imaxdiv.rem == result_exp.rem
+  );
+
   /* Test for strtoimax  */
   puts( "\nstrtoimax Testcases...." );
   puts( "Valid Inputs - Positive Number" );
diff --git a/testsuites/psxtests/psxinttypes01/psxinttypes01.doc b/testsuites/psxtests/psxinttypes01/psxinttypes01.doc
index 19f63af..6fc16f9 100644
--- a/testsuites/psxtests/psxinttypes01/psxinttypes01.doc
+++ b/testsuites/psxtests/psxinttypes01/psxinttypes01.doc
@@ -1,4 +1,4 @@
-This File describes the concepts tested by this test suite.
+This File describes the concepts tested by this test suite.
 
 inttypes.h - fixed size integer types
 
@@ -37,3 +37,11 @@ test suite name: PSXINTTYPE 01
 	- checks for output for string having a negative number - Number Out of Range
 	- checks for final string pointed by endptr
 	- checks for output for invalid argument - Invalid Base
+
+- Checks for imaxabs Testcases
+	- checks for output with an input with any negative number
+	- checks for output with an input with any positive number
+
+- Checks for imaxdiv Testcases
+	- checks for the output quotient and remainder with input with positive numbers
+



More information about the vc mailing list