Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: Sergey Bronnikov <estetus@gmail.com>,
	max.kokryashkin@gmail.com, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] test: introduce asserts assert_str{_not}_equal
Date: Sat, 18 Nov 2023 19:40:56 +0300	[thread overview]
Message-ID: <6bbe0451-345a-40fe-9387-1e107f7a3ba9@tarantool.org> (raw)
In-Reply-To: <ZVXMjrD8dZsln_yl@root>

[-- Attachment #1: Type: text/plain, Size: 4317 bytes --]

Hello,


On 11/16/23 11:02, Sergey Kaplun wrote:


<snipped>

>> diff --git a/test/tarantool-c-tests/lj-881-fix-lua-concat.test.c
>> b/test/tarantool-c-tests/lj-881-fix-lua-concat.test.c
>> index 1835d273..f028c457 100644
>> --- a/test/tarantool-c-tests/lj-881-fix-lua-concat.test.c
>> +++ b/test/tarantool-c-tests/lj-881-fix-lua-concat.test.c
>> @@ -77,7 +77,7 @@ static int lua_concat_testcase(void *test_state)
>>        const char *str = lua_tostring(L, -1);
>>        assert_int_equal(lua_gettop(L), top - 2 + 1);
>>        const char expected_str[] = CONCAT("A + ", TEST_VALUE);
>> -    assert_str_equal(str, expected_str, strlen(expected_str));
>> +    assert_str_equal(str, expected_str);
>>
>>        /* Teardown. */
>>        lua_settop(L, 0);
>> diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h
>> index 2f2d9ea2..5e5c96b2 100644
>> --- a/test/tarantool-c-tests/test.h
>> +++ b/test/tarantool-c-tests/test.h
>> @@ -212,15 +212,15 @@ static inline int todo(const char *reason)
>>        );                                \
>>    } while (0)
>>
>> -#define assert_str_equal(got, expected, n) do {                \
>> -    assert_general(strncmp(got, expected, n) == 0,            \
>> +#define assert_str_equal(got, expected) do {                \
>> +    assert_general(strncmp(got, expected, strlen(expected)) == 0,    \
> On the second thought, I insist on using `strcmp()` here since the
> expected string is always `\0` terminated, and we use "not safe" the
> `strlen()` anyway.


Updated.

diff --git a/test/tarantool-c-tests/test.h b/test/tarantool-c-tests/test.h
index 5e5c96b2..3b22fb92 100644
--- a/test/tarantool-c-tests/test.h
+++ b/test/tarantool-c-tests/test.h
@@ -213,14 +213,14 @@ static inline int todo(const char *reason)
  } while (0)

  #define assert_str_equal(got, expected) do {                           \
-       assert_general(strncmp(got, expected, strlen(expected)) == 0,   \
+       assert_general(strcmp(got, expected) == 0,                      \
                        ASSERT_EQUAL_FMT(str, "%s"),                     \
                        __FILE__, __LINE__, (got), (expected)            \
);                                                              \
  } while (0)

  #define assert_str_not_equal(got, unexpected) do {                     \
-       assert_general(strncmp(got, expected, strlen(expected)) != 0,   \
+       assert_general(strcmp(got, expected) != 0,                      \
                        ASSERT_NOT_EQUAL_FMT(str, "%s"),                 \
                        __FILE__, __LINE__, (got), (unexpected)          \
);                                                              \

>
>>                   ASSERT_EQUAL_FMT(str, "%s"),            \
>>                   __FILE__, __LINE__, (got), (expected)        \
>>        );                                \
>>    } while (0)
>>
>> -#define assert_str_not_equal(got, unexpected, n) do { \
>> -    assert_general(strncmp(got, expected, n) != 0,            \
>> +#define assert_str_not_equal(got, unexpected) do {            \
>> +    assert_general(strncmp(got, expected, strlen(expected)) != 0,    \
> Ditto.
Ditto.
>
>>                   ASSERT_NOT_EQUAL_FMT(str, "%s"),            \
>>                   __FILE__, __LINE__, (got), (unexpected)        \
>>        );                                \
>>
>>>> +                       ASSERT_NOT_EQUAL_FMT(str, "%s"),                 \
>>>> +                       __FILE__, __LINE__, (got), (unexpected)          \
>>>> +        );                                                              \
>>>> +} while (0)
>>>> +
>>>>    #endif /* TARANTOOL_LUAJIT_TEST_H */

[-- Attachment #2: Type: text/html, Size: 5893 bytes --]

  reply	other threads:[~2023-11-18 16:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1698775628.git.sergeyb@tarantool.org>
2023-09-26  6:56 ` [Tarantool-patches] [PATCH luajit] LJ_GC64: Fix lua_concat() Sergey Bronnikov via Tarantool-patches
2023-09-29  8:24   ` Maxim Kokryashkin via Tarantool-patches
2023-10-03 15:35     ` Sergey Bronnikov via Tarantool-patches
2023-10-04 10:48       ` Maxim Kokryashkin via Tarantool-patches
2023-10-06 13:51         ` Sergey Bronnikov via Tarantool-patches
2023-10-31 18:11   ` [Tarantool-patches] [PATCH luajit 1/2] test: introduce asserts assert_str{_not}_equal Sergey Bronnikov via Tarantool-patches
2023-11-01  7:40     ` Sergey Kaplun via Tarantool-patches
2023-11-01  8:28       ` Igor Munkin via Tarantool-patches
2023-11-10 11:41         ` Sergey Bronnikov via Tarantool-patches
2023-11-14  8:55           ` Sergey Kaplun via Tarantool-patches
2023-11-15  9:32             ` Sergey Bronnikov via Tarantool-patches
2023-11-16  8:02               ` Sergey Kaplun via Tarantool-patches
2023-11-18 16:40                 ` Sergey Bronnikov via Tarantool-patches [this message]
2023-11-20  9:28                   ` Sergey Kaplun via Tarantool-patches
2023-11-20 13:19                   ` Igor Munkin via Tarantool-patches
2023-11-10 11:40       ` Sergey Bronnikov via Tarantool-patches
2023-11-23  6:31   ` [Tarantool-patches] [PATCH luajit] LJ_GC64: Fix lua_concat() Igor Munkin via Tarantool-patches

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=6bbe0451-345a-40fe-9387-1e107f7a3ba9@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=estetus@gmail.com \
    --cc=max.kokryashkin@gmail.com \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 1/2] test: introduce asserts assert_str{_not}_equal' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox