From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail-a.sr.ht; dkim=pass header.d=maniero.me header.i=@maniero.me Received: from crane.ash.relay.mailchannels.net (crane.ash.relay.mailchannels.net [23.83.222.43]) by mail-a.sr.ht (Postfix) with ESMTPS id 837EE202AC for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 29 Feb 2024 15:16:20 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 55AB52C0EC1 for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 29 Feb 2024 15:16:17 +0000 (UTC) Received: from fr-int-smtpout5.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 873C02C0C8A for <~johnnyrichard/olang-devel@lists.sr.ht>; Thu, 29 Feb 2024 15:16:16 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709219776; a=rsa-sha256; cv=none; b=f3vMTVmLfMGU04jD1KyaThJL3XtnOBQdUG3dji9rCLo43HAjpnhkKfWoqdrx0ARWrDGKyu tQAwjrcxkBpzE7KGIxivodeNFmGAaSm1H3L6ELmsz/brVyD63z1SAiC5XWd3VC4+gIE/4q aczAT2vB1g/w0Mz6eMpsPpKfbMOqrVEJaf1fyXZF3u9YXpL13yZ7ONB74bO8oW2Oll6/jW MTYPh8cs1sHmp4YhM5mGD+Q91cOOrjViu8Rv1Ak08XikSWVlEkVYAe1Yype/mPdclCrTng ptK0xIz82rpJtzg7Sa2v1M2uth4wlD1umCD7cfjs/0IN8DTvzvxDtcl/uOV1EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709219776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=srci5UnOoTk4ZNibSNw9/KvTu3aKq0azIU/IalJhwNo=; b=l0swzaXICdIuaYuLudco+wNusA/1EJwtkupR+6CPw9G0XfrPlpSxrwyfGmVTYqA9FXsmNh LF3vbQav7w1QdgawwR0pG+ntJ2tJ3a7vscWmMAjnSnS02x/P2EJ04AbFT8PpFWDiMRiPiu lMaIx2F3zIus8qgtDcy2oekygJQpYJ+9jwlLtPIkQa0iFcOFk7uBjC5IzmfADPIyXDg/nq R5oy95a3KiTHW29pDv2F8S1odcEFVFki2gkNQIyqde8jQHL+DFf2hQ3pwDHsYqWFFX0rFC 6HURSZukOkHZj5KOQ+r6S4QPh0G7sLMo50Of2AAwgdC1FEFbtJiZkbkJRcsX0Q== ARC-Authentication-Results: i=1; rspamd-55b4bfd7cb-tc9hf; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Oafish-Shoe: 012f2b1c3fe9104b_1709219777069_3978094256 X-MC-Loop-Signature: 1709219777069:3199039537 X-MC-Ingress-Time: 1709219777069 Received: from fr-int-smtpout5.hostinger.io ([UNAVAILABLE]. [89.116.146.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.124.220.170 (trex/6.9.2); Thu, 29 Feb 2024 15:16:17 +0000 Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1709219770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=srci5UnOoTk4ZNibSNw9/KvTu3aKq0azIU/IalJhwNo=; b=ATlMoNa94n4kWivUZfrbGKDipJAD3Y/+Ujfp/KwTP6vK1DZ24cfuJH+CUoE9xy+tPFnmfc kiqHjYz1JVqhrCvX7TziX/hbFTs3GVVzEpL5+VSWZkv6/8Ni9RoWjHQYl8tZn3XD3fHobG Q9886Zbe5iMvCAdFYoNAt1Qp9PZHZ9dsqYjJTYnXLbnmblndoXsKvG2puEF+vzPomxaN/J 2dVN4SwEhbaEYR6zU+XYRineG3xWvpUQQFj3i0icWrUeionqCn2Uauv36wxcMnaD0ND9Nd LSrauSe0R6nunZKs6vmt4Jn4BUZWW40ITCA0ylga9LP7ahYLX4eGYp7cZ46uOQ== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 29 Feb 2024 12:16:07 -0300 Message-Id: To: "Johnny Richard" , <~johnnyrichard/olang-devel@lists.sr.ht> Subject: Re: [PATCH olang v1 2/4] string_view: add string view conversion to uint32_t From: "Carlos Maniero" X-Mailer: aerc 0.15.2-211-g37d5fc691aff References: <20240228190956.78191-1-johnny@johnnyrichard.com> <20240228190956.78191-3-johnny@johnnyrichard.com> In-Reply-To: <20240228190956.78191-3-johnny@johnnyrichard.com> X-CM-Envelope: MS4xfNDKR+QX2hYiIbwFJLsIhyAzKyz9p6bUEfHC6Kq0xXNroA4nr5QQJxceMayJZIm0mYDs2/0HWIavX9yKVQ2cLtXQH97WNGvsxPBXUnBj5a34RDOl8QtL SpjfFKmUKzTn0mRGCEBGIWH0mRnbRqithML6fDTKr5+brjgipIJb94xst2LYb+lHr6zaqXYCe46odx5iQ3JEtfQFxy2atl1ORzMzgnRNd1h+08w/Wjtt8cvw x735qMEwP6zqw0zLBYBJjQ== X-CM-Analysis: v=2.4 cv=Ys4JRZYX c=1 sm=1 tr=0 ts=65e09fba a=5+VMC1FZ3J4mVPAKpPmAqg==:117 a=5+VMC1FZ3J4mVPAKpPmAqg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=BXDaF_L80NYA:10 a=yVzJRoomjQvOfdD-al8A:9 a=QEXdDO2ut3YA:10 X-AuthUser: carlos@maniero.me X-TUID: NSuUvgMJsvsz First of all, thank you for adding tests to *string_view*. I've just a few small adjustments to ask: > + memset(ret, 0, str.size + 1); > + memcpy(ret, str.chars, str.size); This will iterate *str.size* times twice. Instead of using *memset* you could only set the *NULL terminator* as the last char of *ret*. > +static MunitResult > +string_view_eq_to_cstr_test(const MunitParameter params[], void *user_da= ta_or_fixture) > +{ > + char *name =3D "John Doe"; > + > + string_view_t str =3D { .chars =3D name, .size =3D strlen(name) }; > + > + assert_true(string_view_eq_to_cstr(str, "John Doe")); > + assert_false(string_view_eq_to_cstr(str, "Doe")); > + > + return MUNIT_OK; > +} It would be great if you add also a test taking just a portion of the string to make sure the *.size* is working. > +static MunitResult > +string_view_to_u32_test(const MunitParameter params[], void *user_data_o= r_fixture) > +{ > + char *number =3D "69"; > + > + string_view_t str =3D { .chars =3D number, .size =3D strlen(number) = }; > + > + assert_uint32(string_view_to_u32(str), =3D=3D, 69); > + > + return MUNIT_OK; > +} Same here. Instead of taking the entire number you can get just a digit.