All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: "Tom Rini" <trini@konsulko.com>,
	"Jonathan A . Kollasch" <jakllsch@kollasch.net>,
	"Marek Vasut" <marex@denx.de>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Eugeniu Rosca" <erosca@de.adit-jv.com>,
	"Roland Gaudig" <roland.gaudig@weidmueller.com>,
	"Stefan Herbrechtsmeier" <stefan.herbrechtsmeier@weidmueller.com>,
	"Sean Anderson" <seanga2@gmail.com>,
	"Simon Glass" <sjg@chromium.org>
Subject: [PATCH v2 07/14] lib: Add octal tests for simple_strtoul/l()
Date: Sat, 24 Jul 2021 09:03:34 -0600	[thread overview]
Message-ID: <20210724150341.243074-8-sjg@chromium.org> (raw)
In-Reply-To: <20210724150341.243074-1-sjg@chromium.org>

This function support decoding octal but no tests are included yet.
Add some.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 test/str_ut.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/str_ut.c b/test/str_ut.c
index 880cc928ec8..0d1bf398099 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -17,6 +17,8 @@ static const char str2[] = "1099abNo, don't bother apologising.";
 static const char str3[] = "0xbI'm sorry you're alive.";
 static const char str4[] = "1234567890123 I lost closer friends";
 static const char str5[] = "0x9876543210the last time I was deloused";
+static const char str6[] = "0778octal is seldom used";
+static const char str7[] = "707it is a piece of computing history";
 
 /* Declare a new str test */
 #define STR_TEST(_name, _flags)		UNIT_TEST(_name, _flags, str_test)
@@ -89,6 +91,10 @@ static int str_simple_strtoul(struct unit_test_state *uts)
 		ut_assertok(run_strtoul(uts, str3, 16, 0xb, 3, upper));
 		ut_assertok(run_strtoul(uts, str3, 10, 0, 1, upper));
 
+		/* Octal */
+		ut_assertok(run_strtoul(uts, str6, 0, 63, 3, upper));
+		ut_assertok(run_strtoul(uts, str7, 8, 0x1c7, 3, upper));
+
 		/* Invalid string */
 		ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));
 
@@ -140,6 +146,10 @@ static int str_simple_strtoull(struct unit_test_state *uts)
 		ut_assertok(run_strtoull(uts, str3, 16, 0xb, 3, upper));
 		ut_assertok(run_strtoull(uts, str3, 10, 0, 1, upper));
 
+		/* Octal */
+		ut_assertok(run_strtoull(uts, str6, 0, 63, 3, upper));
+		ut_assertok(run_strtoull(uts, str7, 8, 0x1c7, 3, upper));
+
 		/* Large values */
 		ut_assertok(run_strtoull(uts, str4, 10, 1234567890123, 13,
 					 upper));
-- 
2.32.0.432.gabb21c7263-goog


  parent reply	other threads:[~2021-07-24 15:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-24 15:03 [PATCH v2 00/14] lib: Add support for a decimal 0t prefix for numbers Simon Glass
2021-07-24 15:03 ` [PATCH v2 01/14] hash: Ensure verification hex pairs are terminated Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 02/14] global: Convert simple_strtoul() with hex to hextoul() Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 03/14] global: Convert simple_strtoul() with decimal to dectoul() Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 04/14] lib: Comment the base parameter with simple_strtoul/l() Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 05/14] lib: Drop unnecessary check for hex digit Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 06/14] lib: Add tests for simple_strtoull() Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` Simon Glass [this message]
2021-08-02 17:51   ` [PATCH v2 07/14] lib: Add octal tests for simple_strtoul/l() Tom Rini
2021-07-24 15:03 ` [PATCH v2 08/14] lib: Move common digit-parsing code into a function Simon Glass
2021-08-02 17:51   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 09/14] doc: Convert command-line info to rST Simon Glass
2021-08-02 17:52   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 10/14] doc: Add a note about number representation Simon Glass
2021-08-02 17:52   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 11/14] lib: Allow using 0x when a decimal value is requested Simon Glass
2021-08-02 17:52   ` Tom Rini
2021-07-24 15:03 ` [PATCH v2 12/14] lib: Support a decimal prefix 0n Simon Glass
2021-07-24 15:03 ` [PATCH v2 13/14] lib: Drop octal support Simon Glass
2021-07-24 15:03 ` [PATCH v2 14/14] RFC: Change simple_strtoul() et al to default to hex Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210724150341.243074-8-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=erosca@de.adit-jv.com \
    --cc=jakllsch@kollasch.net \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=roland.gaudig@weidmueller.com \
    --cc=seanga2@gmail.com \
    --cc=stefan.herbrechtsmeier@weidmueller.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.